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