I'm trying to set the value of an eVar via Data Element + Page Load Rule in DTM.
My page has a data layer with multiple object branches, for example:
I can successfully pass values from the dataLayer.pageInfo branch into evars via a DE referencing the js object path as:
e.g. in the PLR, eVar11=%Country%
But, all my DE's pointing to values on the .productInfo branch fail to pass. For example:
...and in the PLR, eVar12=%Style%
To clarify, in both cases, I can type _satellite.getDataElement('country') or _satellite.getDataElement('style') in the console and get the right value to return. But when the AA beacon fires, the evar for country is there, but the evar for style is not.
I have triple-checked for typos 🙂
Any ideas will be greatly appreciated!
It sounds like that specific piece of your data layer may not be populated by the time the Analytics beacon fires.
If you receive the expected value when calling the data element directly via the _satellite console command, then the method you're using to capture the value is obviously working. The most likely cause then becomes timing. How is the data element populated? Is the value scraped from the page directly or is it retrieved via a call to your server?
Are you populating a default value in your data element by chance? If not, I would add a default value in the "Style" data element for testing and see if that is getting passed in the beacon.
Do debug what Jantzen says, in your page load rule, write the datalayer value to the console to validate if that is the case. Youw can do that via the custom code Input/tab.
Thanks for the quick responses!
I tested a default value "test_style" and it did indeed fire as a component of the AA beacon data payload.
@Jantzen, I'm checking with the development team to get specifics on how the data layer is being populated. I believe it's a server call, not a screen scrape. I will work with them to see what can be done about moving the data layer up in the sequence of the page build so that all values populate prior to the AA beacon fire.
If anyone has tips on how to monitor/de-bug data layer build timing, that would help 🙂
Any updates here? Were you able to determine if data layer timing was the root cause of the issue?
I thought of another test that could be run. You could create a page load rule that is triggered "onload". This should delay the rule from firing until all content including images and async scripts have loaded according to the documentation.
This should delay the rule long enough for your values to be returned.