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

Let Google Tag Manager and Javascript



You just saw a Google Tag Manager fire a custom javascript alert !

Here’s how i am doing it:

1. Create Variable

Simple Google Tag Variable

2. Create Trigger

Simple Google Tag Trigger

3. Create Tag

Simple Google Tag Manager

Real World Example…… Sky is your limit, isn’t ?
you want to see the alert pop-up triggered by GTM again.. click here

So the keypoint here:

  • Function you create on a tag can be accessible on your page
  • You need to use {{variablename}} format to access GTM variable

How about retrieve GTM Variables.. like here
 

There are two types of Javascript Variable in Google Tag Manager’s Variable

1. Custom Javascript

Basically this is function that you code inside GTM:

Google Tag Manager Custom Javascript Variable

2. Javascript Variable

Basically this is a global variable in your page that detected by GTM. It would set as undefined when global variable not exist.
Tips: You can also set this variable from Custom HTML Tag

Google Tag Manager Javascript Variable

Use Filter to Output FULL PATH url report

So, you use a single property to all your domain and subdomain, and then you realize that the report on Google Analytics mixed up because of this kind of scenario:

http://domain.com/index.html (10 pageview)
http://sub.domain.com/index.html (40 pageview)
http://super.domain.com/index.html (5 pageview)

Google Analytics only show traffic result of  /index.html with 55 result ! (which most of you think its totally wrong)

Continue reading Use Filter to Output FULL PATH url report