Google Tag Manager Variables List & Usage

Google Tag Manager Variables List & Usage

What are Google Tag Manager Variables?

Variables in Google Tag Manager are name: value pairs for which the value is populated during runtime. It is a storage location where you can keep the URL of the currently loading page or id of any element.

There are two ways to use variables in tag manager. You can use them in triggers as a filter to specify when the trigger should execute i.e execute the trigger when the page path variable matches /thankyou.html. In tags, variables are used to store dynamic values i.e transaction values or conversion tracking tag.

 

Types of Variables

There are mainly two types of Google Tag Manager variables.

  1. Built-in Variables

  2. User Defined variables

Built-in variables are predefined variables and can not be customized. To view, the list of built-in variables navigate to variables tab.

access tag manager variables

To view and enable the built-in variables click on the configure button.

enable built-in variables

Only a few of the specific variables are enabled by default and you will have to enable the other variables to use them. Following is the list of built-in page variables:

Page URL:  returns the string containing the full URL of the current page (http://marketlytics.com/contact/lets-talk)

Page Hostname: returns the string containing the hostname of the currently loaded page (http://marketlytics.com)

Page Path: returns the string containing the relative path of the current page (/contact/lets-talk)

Referrer: returns the string containing the URL of the previously viewed page by the user (http://marketlytics.com/blog)

 

User-Defined Variables in Tag Manager

User-defined variables are those variables which are defined by me and you. These variables are other than those listed in built-in variables. To create a user defined variable you can click on the new button under user defined variables.

For example, you can define a constant variable to save the GA tracking code, which can be used anywhere when needed the GA code.

Click on the New button

Enter the name as ‘gaProperty’

Click on the variable configuration and select constant as the variable type

Enter the GA tracking code in the value field and hit save

user defined variable

Once you understand Google Tag Manager variables, you can easily setup event tracking in Google Tag Manager and many more things.