Can Adobe DTM read JSON such as:
<script type="application/json">
{
"analytics" : [{
"dataLayer" : [{
"tags" : [{
"adobeAnalytics" : true
}],
"pageInfo" : [{
"country" : "us",
"language" : "en",
"siteDescriptor" : "xxx",
"platform" : "web",
"domain" : "xxxxx"
}],
"activities" : [{
"eventType" : "xxxxx",
"eventCity" : "xxxxx",
"eventDate" : "xxxxx"
}]
]}
}]
}`
</script>
Previously I had this as a JavaScript object and created data elements in DTM to read the JS Object. However, due to constraints on the project, we can no longer do this as JavaScript. Is it possible to keep the same structure, add the 'type="application/json"' and keep everything else the same?
Thanks
No, at least not out of the box. You'd need to parse the JSON into a variable before being able to use it in DTM.
<script type="application/json" id="json-datalayer">
{
"analytics": [{
"dataLayer": [{
"tags": [{
"adobeAnalytics": true
}],
"pageInfo": [{
"country": "us",
"language": "en",
"siteDescriptor": "xxx",
"platform": "web",
"domain": "xxxxx"
}],
"activities": [{
"eventType": "xxxxx",
"eventCity": "xxxxx",
"eventDate": "xxxxx"
}]
}]
}]
}
</script>
Then within DTM you could do something similar to (very basic example)
JSON.parse(document.getElementById('json-datalayer').innerHTML)