Update: an interesting article on this topic by YannisG: http://digitalinsightsworld.com/tag-manager/push-datalayer-values-adobe-sitecatalyst-variables-via-dtm/
There is a website with Google Tag Manager and dataLayer installed. I want to try another tag management solution (Adobe DTM) using the same dataLayer, so no more development is needed.
The dataLayer is a list of objects. One of the objects contains "pageview" property, which I want to send to Adobe Analytics on all pageviews.
Object {
event: "virtual PV",
pageview: "/page1",
__proto__: Object}
Let's say I want to get the pageview property from one of the dataLayer's objects and put it into Adobe Analytics "prop1" variable.
What I did in Adobe DTM:
set a custom data element "dataLayer - pageview - page1" as custom script (the script returns a string "/page1", which should be added as "prop1" to Adobe Analytics:
var result = dataLayer.filter(function( obj ) { return obj.event == 'virtual PV'; }); return result[0].pageview
set a page load rule (launched at DOM ready) and set "prop1" variable as: %dataLayer - pageview - page1%.
prop1="%dataLayer - pageview - page1%"
In theory this setup should work and every pageview should have a prop1 = "/page1", however in the console I see the error:
SATELLITE: TypeError - Cannot read property 'pageview' of undefined
What could be the reason? When I type the data element code in the console - it gets the pageview value correctly. Maybe the GTM's dataLayer object is not ready, when DTM wants to extract data from it, so I should delay DTM - but how?