We are looking to capture the total value of an order on the confirmation page. This is currently being sent to GA, so I thought it would be best if we can just re-use that data and store it in Dynatrace.
In the “Session and user action properties” config, if I select “Javascript Variable” and use the following:
window.dataLayer[13].ecommerce.value
It works, but the problem is that 13 is not always the right index.
The best way to get the right value is to run this, so the index can change every time, we just want the last instance of a purchase):
window.dataLayer.findLast((event) => event.event === "purchase").commerce.value
But that gives a message of “Not supported JavaScript expression!” when using the Javascript Variable option.
Is “Javascript function” the option that would work for the example? If so, does anyone know why that might be greyed out in the Dynatrace UI? Could it be because we are using Agentless RUM?
Thanks!