Data Layer

Variable from site can be sent to GTM through Data Layer. There are two method to work with dataLayer

Static Initialization in <head> tag (or previous GTM container’s call) – View Source of this page:

dataLayer_declaration

After page loaded (or after GTM container called):

Try to click this link

dataLayer_declaration_push

 

Note:

dataLayer is a javascript array and it can store one or more multiple object…makes it a complex Array, for example:

dataLayer=[ {

“color”:”Caf\u00e9″,

“price”:164900.00,

“sizeList”:””,

“visitorsHasOrders”:true,

“data”:[45,67,89,20],

“shoppingCart”:[[“Clasicos”,57],[“Zapatos”,456]],

“pageAttributes”:{“page”:”product”},

“pageCategory”:[

{“id”:”20″,”name”:”Zapatos”},

{“id”:”53″,”name”:”Masculino”},

{“id”:”57″,”name”:”Clasicos”},

{“id”:”138″,”name”:”Deportes”},

{“id”:”139″,”name”:”Masculino”}

{“id”:”201″,”name”:”Zapatos”},

{“id”:”1244″,”name”:”Mocasines”},

{“id”:”1340″,”name”:”Apaches”}

]

}];

Read more: http://www.optimizesmart.com/google-tag-manager-data-layer-explained-like-never/#ixzz3mx6QA0ox