How to get values from dataLayer object
Solution 1
You can access the pushed data via the google tag manager javascript-api. The variable part will be the container-id of your GTM container. Make shure you adress the correct one.
google_tag_manager['<container-id>'].dataLayer.get('gtm.start');
//result e.g.: 1210115541132
The result will be the last value of the datalayers state
Solution 2
Print the Data Layer in a table console.table(dataLayer);
and note the index
value it will show for Linker
.
Then you may use dataLayer[XXX]
as XXX
being the index
value for Linker
.
Comments
-
Rakesh Sharma almost 2 years
I want to get some values from dataLayer object of google tag manager. In chrome tag assistance i am getting values like this
[ { "gtm.start": 1503053374849, "event": "gtm.js", "gtm.uniqueEventId": 0 }, { "event": "gtm.dom", "gtm.uniqueEventId": 1 }, { "event": "gtm.load", "gtm.uniqueEventId": 2 }, { "Linker": "_ga=53655374" } ]
I need to get the "Linker" value. i tried
dataLayer[3].Linker
but it gives me "undefined" or blank also same fordataLayer[1].event
(it's blank not return value = "gtm.dom") When i trydataLayer[0].event
it's return correct'gtm.js'
Please help me how to get "Linker" value