29 Feb 2024 06:32 AM - last edited on 10 May 2024 04:02 PM by Michal_Gebacki
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!
Solved! Go to Solution.
29 Feb 2024 12:50 PM
What about adding the property with the SDK?
https://www.dynatrace.com/support/doc/javascriptapi/interfaces/dtrum_types.DtrumApi.html#addActionPr...
01 Mar 2024 05:37 PM
Hi @SG88
Even if you are using Agentless monitoring, you need to add the RUM JavaScript to every HTML page of your application, in that case, you can use the RUM JavaScript API to customize the Real User Monitoring adding action/session properties.
https://docs.dynatrace.com/docs/shortlink/api-rum
03 Mar 2024 10:55 PM
Thanks Cesar, we have the RUM JavaScript injected to each page but I usually try and avoid asking the devs to put in vendor specific code for monitoring.
If a code change is needed then I might just ask if they can put it into a more simple variable that we can read without needing to use a function in the "Session and user action properties" config.
Thanks!