Viewing your Google Tag Manager dataLayer
While you are setting up your Conversion Pixel it may be necessary to view your Data Layer to ensure that variables that you intend to pass to Corvidae are present and correct. To view the Google Tag Manager dataLayer in its unmodified format you can simply execute the following in the browser console:
dataLayer
However this can be difficult to navigate. To simplify the output we have put together a helper function.
flattenObject
Helper Function
To easily view your Google Tag Manager dataLayer execute the following two lines of code in your browser developer console.
const flattenObject=function(t){let e={};for(let n in t)if(t.hasOwnProperty(n)){if("object"==typeof t[n]){let f=flattenObject(t[n]);for(let o in f)f.hasOwnProperty(o)&&(e[n+"."+o]=f[o])}else"function"==typeof t[n]||(e[n]=t[n])}return e};
console.log(flattenObject(dataLayer));
Then expand the resulting object to see your dataLayer variables.
The result is the datalayer flattened into an object of key:value pairs, where the key is the path to its value in dot-notation. Here is an example:
0.event: "gtm.js"
0.gtm.start: 1234567890987
0.gtm.uniqueEventId: 1
1.event: "gtm.dom"
1.gtm.uniqueEventId: 2
2.event: "gtm.load"
2.gtm.uniqueEventId: 3
3.0: "js"
4.0: "set"
4.1: "developer_id.zZqQdDtT"
4.2: true
5.0: "config"
5.1: "AW-123456789"
6.corvidae.conversionId: "12345"
6.corvidae.conversionValue: "123.45"
6.corvidae.currencyCode: "GBP"