I have the following dataLayer array set in the <head> of my HTML page and I have the Adobe Launch script set after it. However when I try to pull the values via Data Element's JavaScript Variable it doesn't work. I tried putting both dataLayer[0].variable1 and dataLayer.variable1 into the "JavaScript variable name" field but both don't work. Does Launch not support dataLayers that are set as an array or is there something I'm missing in the Data Elements set up?
<head>
<script>
dataLayer = [{
'variable1': 'value-of-variable-1',
'variable2': 'value-of-variable-2',
'variable3': 'value-of-variable-3'
}];
</script>
<script src="<adobe launch.js" async></script>
</head>
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
I was able to figure this out. Since the dataLayer is implemented as an array, the Javascript Variable data element needs to be dataLayer.0.[dataLayer element]
To map your data elements, you would pick up the individual data elements as a 'javascript variable' and the javascript variable name would be window.dataLayer.variable1
Views
Replies
Total Likes
This didn't work for me since my dataLayer is set as an array vs as an object.
I did use the Analytics contextData Tools extension and it returned the variables as context variables in the following format:
This works for me for now, but wondering if there's a more optimized way of doing this. Thanks!
Views
Replies
Total Likes
I was able to figure this out. Since the dataLayer is implemented as an array, the Javascript Variable data element needs to be dataLayer.0.[dataLayer element]