Creating variables within Google Tag Manager is one of the many features that make tag management so powerful.
While this is the case across the board, a lot of us stick to the built-in variables because we know they work. There is a lower chance that errors flow into your data since these have been created and vetted by Google.
Don’t let this distract from the powerful variables you can create. There are a few main custom variables you can create in GTM to better help your implementation. Check out the top Google Tag Manager variables to create below.
Don’t want to wait, download an importable container now!
1. GA Base Code – Constant
Most GTM implementation specialists know this one, but I can’t stress the importance and ease of use. Creating a constant variable to house your Google Analytics UA number will save time every day you work with GTM.
Create a new constant variable and insert your Google Analytics UA number (i.e. UA-12345678-9) into the value area. Then, you can recall the variable each and every time that you need to insert the number (i.e. all Google Analytics tags).
2. Element Title – Auto Event Variables
Many times when trying to track the click of a particular element on your site, you pull from different attributes within the element. Sometimes that may be alt text, sometimes the visible text itself or a slew of other attributes.
One attribute that is used often is “title”. If you want to capture that, GTM makes that easy to accomplish through auto event variables.
By creating a new auto event variable you can select a variable type of element attribute. In the attribute name area, enter the name of the attribute (i.e. title) that you want to pull the value of from the element selected.
You can repeat this process for any other element attribute you would like to pull. For a more in-depth look at this, check out element attributes for GTM
Similarly to the Element Title many times we want to pull data that is inserted directly into the page information. One of the most used cases for this is pulling in the page, or document, title.
One request I get from clients more often than not, is how can I accurately pull in the names of PDF downloads on my site for tracking. This used to be a tough answer.
5. URL Host Name – URL Variables
There are a lot of ways that we try to figure out what is and what is not on our own domain. The main reason in tracking analytics is to identify outbound links.
I’ve seen multiple configurations of triggers for tracking outbound links through Google Tag Manager, but the best is by using a custom variable.
Select to create a new GTM variable and this time select URL. There are a few options for Component Type under the URL variable type. For this we will want to select Host Name. After selecting that make sure to check the box to strip the www.
That is all you need to do to enable this powerful variable. From there, if you want to track outbound links, use it in a trigger to fire an outbound link track when that URL Host Name variable does not contain your domain.
There are many different opinions when it comes to the top variables to create in Google Tag Manager. If you are just getting started, or looking for ways to improve your implementation, I hope these help you along.