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

Trigger and Event Tracking

Hello, this page get tracked for a multiple purpose, including:
1. Tracking on Button (Event Tracking)

2. Event Tracking on Outgoing Link

Google

Facebook

Internal Link Sample

3. Event Tracking on Download Link

Download Digital Metrics Playbook

Download Social Media Strategy by Hootsuite

This is a Test TXT File 

4. Youtube Tracking

Hints:

Script for youtube checker

Script for listener

Steps:

  1. Create Custom Variable for checker (yt_checker)
  2. Create Trigger with “DOM Ready” and filter where yt_checker set to true i named it “yt_checktrigger”
  3. Create new Custom HTML tag, use listener scipt above and use “yt_checktrigger” as Trigger
  4. The listener script send 4 parameter:
    1. eventName: ‘youtube’
    2. eventCategory: ‘Youtube Videos’
    3. eventAction: <<theVideo Title>>
    4. eventLabel: <<theVideo event info / length>>

      You need to create DataLaer Variable for eventCategory, eventAction, and eventLabel

  5. Create new trigger, its a Custom Event, and use event name ‘youtube’. i named this trigger ‘YT_Action’
  6. Create new tag, set to Analytics Event, then assign Category, Action, Label as parameter on step 4. Use ‘custom event’ as trigger and set to ‘YT_Action’
  7. Preview and Publish