{"id":153225,"date":"2025-03-24T07:33:18","date_gmt":"2025-03-24T07:33:18","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/variable-guide-for-google-tag-manager\/"},"modified":"2025-03-24T07:33:18","modified_gmt":"2025-03-24T07:33:18","slug":"variable-guide-for-google-tag-manager","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=153225","title":{"rendered":"Variable Guide For Google Tag Manager"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<p><em>(Updated 21 February 2019)<\/em><\/p>\n<p>The <a href=\"http:\/\/analytics.blogspot.fi\/2014\/10\/making-tag-management-more-accessible.html\">current version<\/a> of <a href=\"https:\/\/tagmanager.google.com\">Google Tag Manager<\/a> was released in October 2014. With the release, we saw a brand-spanking new UI, a lot of new functionalities (revamped <a href=\"https:\/\/www.simoahava.com\/analytics\/auto-event-tracking-gtm-2-0\/\">auto-event tracking<\/a>, for example), plus a new terminology to cope with. We moved away from the programming-centric concepts of <em>Macros<\/em> and <em>Rules<\/em> to the more tactile <em>variables<\/em> and <em>triggers<\/em>.<\/p>\n<p>It\u2019s difficult to rank the changes. The new <a href=\"https:\/\/www.simoahava.com\/analytics\/auto-event-tracking-gtm-2-0\/\">Auto-Event Tracking<\/a> is perhaps most impactful, but the improvements done to triggers and variables, when compared to the previous version of GTM, require attention as well.<\/p>\n<div style=\"aspect-ratio: 1246 \/ 562;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/variable-guide.jpg\" title=\"variable guide for google tag manager\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"562\" width=\"1246\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/variable-guide.jpg#ZgotmplZ\" alt=\"variable guide for google tag manager\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>Thus, I give you my variable Guide for Google Tag Manager. For reference, feel free to take a look at the old <a href=\"https:\/\/www.simoahava.com\/analytics\/macro-guide-google-tag-manager\/\">macro guide<\/a>, since especially the different variable types have been left largely untouched.<\/p>\n<p>                <span class=\"simmer\"><br \/>\n  <span class=\"close\">X<\/span><\/p>\n<p>\n    <span class=\"fa fa-md fa-bell\"\/><br \/>\n    <strong>The Simmer Newsletter<\/strong>\n  <\/p>\n<p>\n    Subscribe to the <a href=\"https:\/\/www.simoahava.com\/newsletter\/\">Simmer newsletter<\/a> to get the latest news and content from Simo Ahava into your email inbox!\n  <\/p>\n<p>  <\/span><\/p>\n<h2 id=\"introduction-to-variables\">Introduction to Variables<\/h2>\n<p>In computing terms, <em>variables<\/em> denote compartments in computer memory, which are reserved for storing values. This is a significant achievement in efficiency, because it means that values can be reused across functions, procedures, and environments. The alternative would be to treat each representation of the same value as unique, temporary, and disposable, creating a mass of redundancy and inefficiency, and making the current computing landscape a whole lot different.<\/p>\n<p>In Google Tag Manager, the term <em>variable<\/em> is used to denote a helper function that your tags, triggers, and other variables can invoke to retrieve values from. Thus, the idea is very similar to the broader concept of computing <em>variables<\/em> explored in the previous paragraph.<\/p>\n<p>In GTM, invoking the variable function is done with a specific syntax:<\/p>\n<p><strong>{{variable name}}<\/strong><\/p>\n<p>As we\u2019ll learn later on, you can\u2019t invoke variables wherever you\u2019d want to. But in an approved context, the syntax <strong>{{variable name}}<\/strong> would run the underlying function of the variable with the name \u201cvariable name\u201d, and pass the value returned by that function to its execution context (the tag, trigger, or variable where the syntax was used).<\/p>\n<p>One of the first things all Google Tag Manager containers which run <a href=\"https:\/\/www.google.com\/analytics\">Google Analytics<\/a> tags should do is this:<\/p>\n<div style=\"aspect-ratio: 690 \/ 494;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/gatc-constant.jpg\" title=\"constant variable google analytics tracking code\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"494\" width=\"690\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/gatc-constant.jpg#ZgotmplZ\" alt=\"constant variable google analytics tracking code\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>Here, instead of always typing the tracking code for your web property (UA-XXXXXX-X) into each GA tag, you can create a Constant variable, which stores the value. Thus, whenever the variable name is invoked using the correct syntax, the tracking code returned by the Constant variable will be included in the appropriate tag field. This is something I\u2019ve actually written a <a href=\"https:\/\/www.simoahava.com\/gtm-tips\/save-gatc-constant-string-macro\/\">#GTMtips post<\/a> about this.<\/p>\n<p>I will go so far as to say that variables can make or break GTM. When skeptics ask me what is the main benefit of having GTM on the site, I always end up talking about variables. They add a level of flexibility and customization that can really make your tagging lean, efficient, performance-driven, and time-saving.<\/p>\n<p>At the same time, variables can be difficult to fathom, especially when we get to the technical details (see below), or when we try to tackle the amazingly multi-faceted and deviously difficult Custom JavaScript variable. I hope this guide will help you get to the bottom of variables, and encourage you to find your own ways of performing <a href=\"https:\/\/www.simoahava.com\/analytics\/macro-magic-google-tag-manager\/\">magic<\/a> tricks with your GTM container.<\/p>\n<h2 id=\"technical-details-and-how-to\">Technical details and how-to<\/h2>\n<p>For you to be able to invoke a GTM variable, you need to be working in a <em>script context<\/em>, or the template field needs to support variable references.<\/p>\n<p>A supported template field can be uncovered by looking for the little variable symbol next to a field:<\/p>\n<div style=\"aspect-ratio: 1376 \/ 860;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/variable-context.jpg\" title=\"variable context in GTM tags\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"860\" width=\"1376\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/variable-context.jpg#ZgotmplZ\" alt=\"variable context in GTM tags\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>As you can see, the \u201cTag firing priority\u201d field will <em>not<\/em> be able to invoke a variable, but the \u201cAuto Link Domains\u201d will. In fact, if you click the little variable icon, you will see a drop-down list from which you can pick the variable you want to use. This way you don\u2019t have to worry about correct syntax, as GTM will do it for you.<\/p>\n<div style=\"aspect-ratio: 712 \/ 538;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/drop-down-menu.jpg\" title=\"variable menu\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"538\" width=\"712\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/drop-down-menu.jpg#ZgotmplZ\" alt=\"variable menu\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The other places where you\u2019ll frequently run into variables are:<\/p>\n<ol>\n<li>\n<p>Triggers<\/p>\n<\/li>\n<li>\n<p>Custom HTML tags<\/p>\n<\/li>\n<li>\n<p>Custom JavaScript variables<\/p>\n<\/li>\n<\/ol>\n<p>With triggers (remember to read my <a href=\"https:\/\/www.simoahava.com\/analytics\/trigger-guide-google-tag-manager\/\">Trigger guide<\/a> as well!), you will always need to specify a variable as the target of the trigger condition. Every single trigger condition needs a variable that is evaluated against some value. In fact, the condition builder is created so that you can\u2019t possibly <em>not<\/em> choose a variable. It\u2019s obligatory!<\/p>\n<div style=\"aspect-ratio: 1790 \/ 742;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/trigger-selector.jpg\" title=\"trigger selector menu\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"742\" width=\"1790\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/trigger-selector.jpg#ZgotmplZ\" alt=\"trigger selector menu\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>Note that the <strong>value<\/strong> (right-hand) field of the trigger condition is <strong>NOT<\/strong> a variable context!<\/p>\n<p>As for Custom HTML tags and Custom JavaScript variables, you can call variables from the scripts within, but you won\u2019t have the helpful drop-down menu to assist you. You will need to manually type the call, using the correct syntax and the correct (case-sensitive) variable name:<\/p>\n<div class=\"highlight\">\n<pre style=\"background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-html\" data-lang=\"html\"><span style=\"color:#aaa;font-style:italic\"><!-- Sample Variable call in a Custom HTML Tag --><\/span>\nscript&gt;\n  (<span style=\"color:#00a\">function<\/span>() {\n    alert({{custom alert string}});\n  })();\n<span style=\"color:#1e90ff;font-weight:bold\">script<\/span>&gt;<\/code><\/pre>\n<\/div>\n<p>The code above will pop-up a browser alert, where the content will be the string returned by the variable named <strong>custom alert string<\/strong>. Note! If the variable doesn\u2019t return a string, you might run into problems with the <code>alert<\/code> method, so you need to be well aware of return types and values at all times.<\/p>\n<p>If you try to use a variable that doesn\u2019t exist (or whose name you mistyped), you won\u2019t be able to perform any operations on the container version (create, publish, etc.). You\u2019ll run into an error message that looks like this:<\/p>\n<div style=\"aspect-ratio: 1228 \/ 438;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/variable-error.jpg\" title=\"variable Error GTM\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"438\" width=\"1228\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/variable-error.jpg#ZgotmplZ\" alt=\"variable Error GTM\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>So remember to check all the places where you\u2019ve manually typed a variable call. It\u2019s also possible that you\u2019ve jumped the gun and called a variable, but then you forgot to create the variable itself. Retrace your steps and fix any broken links.<\/p>\n<p>One cool thing that GTM does for you is this: when you change a variable name, <strong>all<\/strong> references to the variable are automatically updated. Even the ones you\u2019ve typed in manually into Custom HTML tags and Custom JavaScript variables! This is incredibly time-saving, since you don\u2019t have to go through every single reference, rewriting the code to match the new name.<\/p>\n<p>Variables are <strong>resolved<\/strong> according to the following process:<\/p>\n<ul>\n<li>\n<p>If the variable is not attached to a trigger or a tag, <strong>the variable is never resolved<\/strong> (unless, of course, the variable is referenced from some other variable that <em>is<\/em> resolved).<\/p>\n<\/li>\n<li>\n<p>If the variable is referenced in a trigger that is not attached to any tags, <strong>the variable is never resolved<\/strong>.<\/p>\n<\/li>\n<li>\n<p>If the variable is referenced in a trigger that is attached to a tag, <strong>the variable is resolved every single time an <code>event<\/code> key is pushed into <code>dataLayer<\/code><\/strong>.<\/p>\n<\/li>\n<li>\n<p>If the variable is referenced in a tag, <strong>the variable is resolved every single time the tag fires<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p>The last one is interesting. When a trigger causes a tag to \u201cfire\u201d, the process is actually this:<\/p>\n<ol>\n<li>\n<p>Variable calls are transformed into the actual function calls (<code>google_tag_manager['containerId'].macro('gtm10')<\/code>)<\/p>\n<\/li>\n<li>\n<p>The tag code is injected on the site<\/p>\n<\/li>\n<li>\n<p>The tag code is executed, and all variable functions within are resolved<\/p>\n<\/li>\n<\/ol>\n<p>As you can see, a variable is actually a method of the <code>google_tag_manager<\/code> object. The parameter that is given to the <code>macro()<\/code> method is basically \u2018gtm\u2019 plus a unique sequential number. This means that it\u2019s very difficult to identify which <code>macro()<\/code> parameter is associated with which variable, which is why debugging has become an all-important tool in understanding how variables work.<\/p>\n<p>The other, common case of variable resolution has to do with trigger conditions. When an \u2018event\u2019 key is pushed into <code>dataLayer<\/code>, every single trigger that is attached to a tag in your container is evaluated for the \u2018event\u2019 condition. In addition to checking the <code>event<\/code> value, all variables referenced in the trigger are evaluated, too.<\/p>\n<p>You might want to re-read the previous paragraphs to grasp the idea, but this has very severe repercussions on how variables should (and should not be used):<\/p>\n<p><strong>Variables must never have side effects<\/strong><\/p>\n<p>Remember how variables should only be used to return values? Well, sometimes you might be tempted to use a variable to change the state of the global object or to set or push stuff into <code>dataLayer<\/code>. <strong>Don\u2019t do it!<\/strong> Because variables can be resolved in multiple ways, and not just in tags as you\u2019d expect, you might find yourself creating infinite loops, pushing stuff into <code>dataLayer<\/code> multiple times, or severely hurting page performance.<\/p>\n<div class=\"highlight\">\n<pre style=\"background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-javascript\" data-lang=\"javascript\"><span style=\"color:#00a\">function<\/span>() {\n  <span style=\"color:#aaa;font-style:italic\">\/\/ DON'T DO THIS:\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>  <span style=\"color:#0aa\">window<\/span>.dataLayer.push({\n    ...\n  });\n  <span style=\"color:#aaa;font-style:italic\">\/\/ OR THIS:\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>  alert(<span style=\"color:#a50\">\"test\"<\/span>);\n  <span style=\"color:#aaa;font-style:italic\">\/\/ OR THIS:\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>  <span style=\"color:#0aa\">window<\/span>.temp = getTempValue();\n  <span style=\"color:#aaa;font-style:italic\">\/\/ DO THIS:\n<\/span><span style=\"color:#aaa;font-style:italic\"\/>  <span style=\"color:#00a\">var<\/span> a = <span style=\"color:#0aa\">window<\/span>.thisValue;\n  <span style=\"color:#00a\">var<\/span> b = getSomeOtherValue();\n  <span style=\"color:#00a\">return<\/span> a + <span style=\"color:#a50\">': '<\/span> + b;\n}\n<\/code><\/pre>\n<\/div>\n<p>If you\u2019ve made it this far, congratulations. As a developer, I think it\u2019s all-important to understand how variables work beyond the obvious, if only to realize the potential that variables have in improving the efficiency of your work with GTM.<\/p>\n<h2 id=\"built-in-variables\">Built-in Variables<\/h2>\n<p>The new version of Google Tag Manager introduced Built-in variables. These are helpful, most commonly used variables, whose existence is based on binary logic: active \/ inactive. If the Built-in variable is activated, it can be used as any other variable, and if it\u2019s not activated, it can\u2019t.<\/p>\n<p>Built-in variables are thus no more than a shorthand for exploiting some of the most frequently used variable types in Google Tag Manager. I find it a bit odd that they\u2019re not all activated by default, since there\u2019s absolutely no harm in them being available for use.<\/p>\n<p>You will find the Built-in variables displayed prominently in the top of the variables screen of your Google Tag Manager Container:<\/p>\n<div style=\"aspect-ratio: 1142 \/ 674;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/built-in-variables-gtm.jpg\" title=\"Built-in Variables\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"674\" width=\"1142\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/built-in-variables-gtm.jpg#ZgotmplZ\" alt=\"Built-in Variables\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>If the Built-in variable is listed here, it is active in the container. To add new Built-in variables, click the red <strong>CONFIGURE<\/strong> button, and check the box next to each variable you want to add to the container.<\/p>\n<div style=\"aspect-ratio: 1242 \/ 740;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/configure-built-in-variables.jpg\" title=\"Configure built-in variables\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"740\" width=\"1242\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/configure-built-in-variables.jpg#ZgotmplZ\" alt=\"Configure built-in variables\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>As with all variables, if the Built-in variable cannot be resolved (e.g. there was no Click action and you want to use Click ID), the variable returns the JavaScript <em>undefined<\/em> type.<\/p>\n<p>Here are the Built-in variables with a brief description of what they return:<\/p>\n<h3 id=\"pages\">Pages<\/h3>\n<ul>\n<li>\n<p><strong>Page URL<\/strong> &#8211; returns a string containing the full URL of the current page without hash fragment  (<code>https:\/\/www.simoahava.com\/article?parameter=true<\/code>)<\/p>\n<\/li>\n<li>\n<p><strong>Page Hostname<\/strong> &#8211; returns a string containing the the hostname of the current page (<code>www.simoahava.com<\/code>)<\/p>\n<\/li>\n<li>\n<p><strong>Page Path<\/strong> &#8211; returns a string containing the relative path of the current page (<code>\/article<\/code>)<\/p>\n<\/li>\n<li>\n<p><strong>Referrer<\/strong> &#8211; returns a string containing the URL of the page which brought the visitor to the current page (<code>https:\/\/www.simoahava.com\/home\/<\/code>), from <code>document.referrer<\/code><\/p>\n<\/li>\n<\/ul>\n<h3 id=\"utilities\">Utilities<\/h3>\n<ul>\n<li>\n<p><strong>Event<\/strong> &#8211; returns a string containing the value stored in the \u2018event\u2019 <code>dataLayer<\/code> key<\/p>\n<\/li>\n<li>\n<p><strong>Environment Name<\/strong> &#8211; returns the name of the <a href=\"https:\/\/www.simoahava.com\/analytics\/better-qa-with-google-tag-manager-environments\/\">environment<\/a> currently being previewed (either via the Share Preview link or the environment\u2019s container snippet)<\/p>\n<\/li>\n<li>\n<p><strong>Container ID<\/strong> &#8211; returns a string containing the container ID (<em>GTM-XXXXXX<\/em>)<\/p>\n<\/li>\n<li>\n<p><strong>Container Version<\/strong> &#8211; returns a string containing the current container version<\/p>\n<\/li>\n<li>\n<p><strong>Random Number<\/strong> &#8211; returns a number, randomized between 0 and 2147483647<\/p>\n<\/li>\n<li>\n<p><strong>HTML ID<\/strong> &#8211; returns the identifier of the Custom HTML tag. Used with <a href=\"https:\/\/www.simoahava.com\/analytics\/understanding-tag-sequencing-in-google-tag-manager\/\">tag sequencing<\/a>.<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"errors\">Errors<\/h3>\n<ul>\n<li>\n<p><strong>Error Message<\/strong> &#8211; returns a string containing the error message dispatched by a JavaScript Error trigger<\/p>\n<\/li>\n<li>\n<p><strong>Error Line<\/strong> &#8211; returns a string containing the line number where the error was thrown<\/p>\n<\/li>\n<li>\n<p><strong>Error URL<\/strong> &#8211; returns a string containing the URL of the script where the error was thrown<\/p>\n<\/li>\n<li>\n<p><strong>Debug Mode<\/strong> &#8211; returns a Boolean (true\/false) depending on if the user is in GTM debug mode or not<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"clicks\">Clicks<\/h3>\n<ul>\n<li>\n<p><strong>Click Element<\/strong> &#8211; returns an HTML element that was the target of an auto-event action; this object is retrieved from the <code>gtm.element<\/code> key in <code>dataLayer<\/code><\/p>\n<\/li>\n<li>\n<p><strong>Click Classes<\/strong> &#8211; returns a string contained in the <code>className<\/code> attribute value of the auto-event element<\/p>\n<\/li>\n<li>\n<p><strong>Click ID<\/strong> &#8211; returns a string contained in the <code>id<\/code> attribute value of the auto-event element<\/p>\n<\/li>\n<li>\n<p><strong>Click Target<\/strong> &#8211; returns a string contained in the <code>target<\/code> attribute value of the auto-event element<\/p>\n<\/li>\n<li>\n<p><strong>Click URL<\/strong> &#8211; returns a string contained in the <code>href<\/code> or <code>action<\/code> attribute value of the auto-event element<\/p>\n<\/li>\n<li>\n<p><strong>Click Text<\/strong> &#8211; returns a string contained in the <code>textContent \/ innerText<\/code> attribute value of the auto-event element<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"forms\">Forms<\/h3>\n<p>These are exactly the same as the Click variables. I\u2019m not sure why we need two sets of variables, when one generic \u201cAuto-Event\u201d type would suffice.<\/p>\n<h3 id=\"history\">History<\/h3>\n<ul>\n<li>\n<p><strong>New History Fragment<\/strong> &#8211; returns a string containing the new URL fragment after a page history change auto-event action is registered<\/p>\n<\/li>\n<li>\n<p><strong>Old History Fragment<\/strong> &#8211; returns a string containing the previous URL fragment<\/p>\n<\/li>\n<li>\n<p><strong>New History State<\/strong> &#8211; returns an object containing the new history state after a <code>pushState()<\/code> has been registered<\/p>\n<\/li>\n<li>\n<p><strong>Old History State<\/strong> &#8211; returns an object containing the old history state<\/p>\n<\/li>\n<li>\n<p><strong>History Source<\/strong> &#8211; returns a string describing the event that initiated the history change (e.g. <code>popstate<\/code> or <code>pushState<\/code>)<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"videos\">Videos<\/h3>\n<ul>\n<li>\n<p><strong>Video Provider<\/strong> &#8211; returns a string containing the video service being tracked (currently <a href=\"https:\/\/www.simoahava.com\/analytics\/the-youtube-video-trigger-in-google-tag-manager\/\">YouTube<\/a> only supported).<\/p>\n<\/li>\n<li>\n<p><strong>Video Status<\/strong> &#8211; returns a string with the status of the video that caused the trigger to fire. Could be one of <code>'start'<\/code>, <code>'pause'<\/code>, <code>'buffering'<\/code>, <code>'progress'<\/code>, or <code>'complete'<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong>Video URL<\/strong> &#8211; returns a string with the URL of the embedded video.<\/p>\n<\/li>\n<li>\n<p><strong>Video Title<\/strong> &#8211; returns a string with the title of the embedded video.<\/p>\n<\/li>\n<li>\n<p><strong>Video Duration<\/strong> &#8211; returns a number with the total length of the video in seconds.<\/p>\n<\/li>\n<li>\n<p><strong>Video Current Time<\/strong> &#8211; returns a number with the time mark where the user currently is (i.e. when the event was triggered).<\/p>\n<\/li>\n<li>\n<p><strong>Video Percent<\/strong> &#8211; returns a number with the percentage mark where the user currently is.<\/p>\n<\/li>\n<li>\n<p><strong>Video Visible<\/strong> &#8211; returns <code>true<\/code> or <code>false<\/code>, depending on if the video was visible in the browser viewport when the event was triggered.<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"scrolling\">Scrolling<\/h3>\n<ul>\n<li>\n<p><strong>Scroll Depth Threshold<\/strong> &#8211; returns a number with the value of the <a href=\"https:\/\/www.simoahava.com\/analytics\/scroll-depth-trigger-google-tag-manager\/\">scroll tracking<\/a> threshold that was crossed (e.g. <code>25<\/code> for 25 percent or 25 pixels, depending on which the trigger is configured with).<\/p>\n<\/li>\n<li>\n<p><strong>Scroll Depth Units<\/strong> &#8211; returns a string with <code>'percent'<\/code> or <code>'pixels'<\/code>, depending on which threshold type the trigger is tracking.<\/p>\n<\/li>\n<li>\n<p><strong>Scroll Direction<\/strong> &#8211; returns a string with <code>'vertical'<\/code> or <code>'horizontal'<\/code>, depending on which direction is being tracked with the trigger.<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"visibility\">Visibility<\/h3>\n<ul>\n<li>\n<p><strong>Percent Visible<\/strong> &#8211; returns a number with the percentage of visibility for the <a href=\"https:\/\/www.simoahava.com\/analytics\/element-visibility-trigger-google-tag-manager\/\">element whose visibility is being tracked<\/a> (e.g. <code>50<\/code> if half of the element is in the viewport).<\/p>\n<\/li>\n<li>\n<p><strong>On-Screen Duration<\/strong> &#8211; returns a number with the total cumulative time (in milliseconds) that the element has been in the viewport when the trigger fires.<\/p>\n<\/li>\n<\/ul>\n<p>As you can see, the Built-in variables are just a quicker way to access some of the most common variable types. Read on, and check especially the chapter on variable types, as that will help you understand Built-in variables better as well.<\/p>\n<h2 id=\"debugging-variables\">Debugging Variables<\/h2>\n<p>In the amazingly wonderful <a href=\"https:\/\/support.google.com\/tagmanager\/answer\/6107056\">Debug Mode<\/a>, there\u2019s a tab for variables:<\/p>\n<div style=\"aspect-ratio: 1516 \/ 526;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/debug-variables.jpg\" title=\"debug mode variables\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"526\" width=\"1516\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/debug-variables.jpg#ZgotmplZ\" alt=\"debug mode variables\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>By clicking that tab, you can explore the <strong>state of each variable upon every single <code>dataLayer<\/code> interaction<\/strong>. <a href=\"https:\/\/www.simoahava.com\/analytics\/google-tag-manager-data-model\/\">As you probably know<\/a>, every single push to the <code>dataLayer<\/code> has the potential to change the state of the data used by GTM, which is why you must be able to observe this state with every interaction. And this is what the variables section of the Debug pane enables you to do.<\/p>\n<p>For example, here are two different <em>states<\/em> of <code>dataLayer<\/code>. The first state is when the Container snippet is first loaded, and the \u2018event\u2019 key is pushed with the value \u2018gtm.js\u2019:<\/p>\n<div style=\"aspect-ratio: 1550 \/ 522;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/pageview-debug.jpg\" title=\"Pageview debug mode\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"522\" width=\"1550\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/pageview-debug.jpg#ZgotmplZ\" alt=\"Pageview debug mode\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>As you can see, I\u2019ve selected the \u201cPage View\u201d event in the left-hand-side navigation of the Debug pane. This corresponds to a <code>dataLayer.push()<\/code>, where the \u2018event\u2019 key was populated with \u2018gtm.js\u2019.<\/p>\n<p>Next, I select the \u201cWindow Loaded\u201d event from the navigation. Here\u2019s what the \u2018event\u2019 key looks like in this particular state:<\/p>\n<div style=\"aspect-ratio: 1500 \/ 530;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/pageload-debug.jpg\" title=\"Window loaded debug mode\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"530\" width=\"1500\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/pageload-debug.jpg#ZgotmplZ\" alt=\"Window loaded debug mode\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>As you can see, the value of the \u2018event\u2019 key has changed. So with the debug pane, you can explore the values stored in each variable at any given <code>dataLayer<\/code> interaction.<\/p>\n<p>If a variable has the value <em>undefined<\/em>, it means that the variable did not resolve. If you see this value in a state where you are certain the variable <em>should<\/em> have a proper value, it means there\u2019s something wrong with your variables, tags, or triggers, and you need to look into it more carefully.<\/p>\n<p>By clicking the Tags tab, you can examine what your variables returned in any tag that has fired (or not):<\/p>\n<div style=\"aspect-ratio: 1392 \/ 490;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/debug-tags.jpg\" title=\"Debug tags\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"490\" width=\"1392\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/debug-tags.jpg#ZgotmplZ\" alt=\"Debug tags\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>You can also look at tags which <em>didn\u2019t fire<\/em>, and focus on the trigger. The visual display will tell you which variable condition did not pass the check, and you\u2019ll know there\u2019s something for you to debug again:<\/p>\n<div style=\"aspect-ratio: 1170 \/ 504;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/debug-triggers.jpg\" title=\"Debug triggers\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"504\" width=\"1170\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/debug-triggers.jpg#ZgotmplZ\" alt=\"Debug triggers\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The Debug tool is incredibly useful, as it allows you to double-check how variables work in your current setup.<\/p>\n<h2 id=\"variable-types\">Variable Types<\/h2>\n<div style=\"aspect-ratio: 1250 \/ 1410;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/variable-types.jpg\" title=\"Variable types\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"1410\" width=\"1250\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/variable-types.jpg#ZgotmplZ\" alt=\"Variable types\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>There are a number of useful variable types for you to choose from, and you can use the Custom JavaScript variable to create custom variables of your own. Many of the variable types have some cool customization options as well, so you should take the time to study their many uses.<\/p>\n<h2 id=\"1-http-referrer\">1. HTTP Referrer<\/h2>\n<div style=\"aspect-ratio: 872 \/ 494;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/http-referrer.jpg\" title=\"HTTP Referrer\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"494\" width=\"872\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/http-referrer.jpg#ZgotmplZ\" alt=\"HTTP Referrer\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>Use the <strong>HTTP Referrer<\/strong> variable to identify details about the page that brought the visitor to the current one. The value is retrieved from the <code>document.referrer<\/code> property. <strong>Note<\/strong>: There is a Built-In variable for this (Referrer).<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p><em>String<\/em> with the URL of the referring page. You can specify a URL component if you wish (see the URL variable for more information about the various component types).<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>You could create a trigger which fires when HTTP Referrer does not contain your own domain. This would mean that the user arrived from outside your site to the current page.<\/p>\n<h2 id=\"2-url\">2. URL<\/h2>\n<div style=\"aspect-ratio: 712 \/ 538;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/url-variable-1.jpg\" title=\"URL Variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"538\" width=\"712\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/url-variable-1.jpg#ZgotmplZ\" alt=\"URL Variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>URL<\/strong> variable can be used to access components of the current page URL (default) or of any URL string returned by a variable. This is a very versatile variable type, and is especially useful for traversing query parameters and hash fragments in your URLs. <strong>Note<\/strong>: There are Built-In variables for this (Page URL, Page Hostname, Page Path).<\/p>\n<p>The Component Types you can choose are:<\/p>\n<p><strong>Full URL<\/strong> &#8211; returns the full URL without the hash fragment, e.g. \u2018<a href=\"https:\/\/www.simoahava.com\/?home=true'\">https:\/\/www.simoahava.com\/?home=true&#8217;<\/a>.<\/p>\n<p><strong>Protocol<\/strong> &#8211; returns the protocol of the URL, e.g. \u2018https\u2019.<\/p>\n<p><strong>Host Name<\/strong> &#8211; returns the hostname of the URL without the port number, e.g. <code>www.simoahava.com<\/code>. You can choose to <em>Strip \u2018www.&#8217;<\/em> to strip the \u2018www\u2019 subdomain from the hostname.<\/p>\n<p><strong>Port<\/strong> &#8211; returns the port number used in the URL, or \u201880\u2019 for HTTP \/ \u2018443\u2019 for HTTPS, if the URL has no port number.<\/p>\n<p><strong>Path<\/strong> &#8211; returns only the pathname in the URL. You can also specify <em>Default Pages<\/em> to strip pages with names like \u2018index.html\u2019 or \u2018index.php\u2019 from the return string.<\/p>\n<p><strong>Query<\/strong> &#8211; returns the entire query parameter string (without leading \u2018?&#8217;), if you don\u2019t specify a query key. If you do specify a query key, only the value of this key is returned, or <em>undefined<\/em> if no such key is found in the URL.<\/p>\n<p><strong>Fragment<\/strong> &#8211; returns the value of the URL\u2019s fragment without the leading \u2018#\u2019, e.g. \u2018anchor1\u2019.<\/p>\n<p>You can expand the <em>More Settings<\/em> tab to find a source selector. In this selector, you can choose the variable whose return value the URL variable will access.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>The return value for the URL type you specified in the Component Type selection, or <em>undefined<\/em> if no such component is found in the URL variable. By default, the URL variable that is accessed is the page URL, but you can choose any variable which returns a string with a URL in it.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>This is, again, a very versatile variable. For example, check the following article for an example of how to use the URL variable to fix your site\u2019s internal search tracking:<\/p>\n<h2 id=\"3-first-party-cookie\">3. First Party Cookie<\/h2>\n<div style=\"aspect-ratio: 814 \/ 540;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/1st-party-cookie-1.jpg\" title=\"1st Party Cookie Variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"540\" width=\"814\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/1st-party-cookie-1.jpg#ZgotmplZ\" alt=\"1st Party Cookie Variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>1st Party Cookie<\/strong> variable returns the value for the first browser cookie with the name you specify in the Cookie Name field. For example, if you have a cookie called \u201csession\u201d, you can use the 1st Party Cookie variable to retrieve the value for this particular cookie.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p><em>String<\/em> containing the value stored in the cookie, or <em>undefined<\/em>, if no such cookie exists.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>I\u2019ve used cookies a lot in my guides. Here are two examples for using cookies:<\/p>\n<h2 id=\"4-custom-javascript\">4. Custom JavaScript<\/h2>\n<div style=\"aspect-ratio: 842 \/ 502;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/custom-javascript-1.jpg\" title=\"Custom JavaScript Variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"502\" width=\"842\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/custom-javascript-1.jpg#ZgotmplZ\" alt=\"Custom JavaScript Variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Custom JavaScript<\/strong> variable is surely the most versatile variable in the set. You can use it to run arbitrary JavaScript on the page. It creates a script context, meaning you can also call other variables from within using the appropriate syntax.<\/p>\n<p>The Custom JavaScript variable needs to follow two simple rules. First, the script must be wrapped in an anonymous function block (<code>function() { ... }<\/code>). Second, the function must have a return statement (<code>return somevalue;<\/code>).<\/p>\n<p>The third, unwritten rule is that the function should only return a value. You shouldn\u2019t use a Custom JavaScript variable to modify the global namescape by pushing values to <code>dataLayer<\/code> for example. If you want to tamper with global variables from a function, it\u2019s better to create a Custom HTML tag for this purpose.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>Depends on what you have in the <code>return<\/code> statement. You can return any variable or value, even other functions, other GTM variables, or nothing (a simple <code>return;<\/code> is the equivalent of returning the <em>undefined<\/em> value).<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>Many of my articles use the Custom JavaScript variable to some extent. Take a look at these to get started:<\/p>\n<h2 id=\"5-data-layer-variable\">5. Data Layer Variable<\/h2>\n<div style=\"aspect-ratio: 852 \/ 622;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/data-layer-variable-1.jpg\" title=\"Data Layer Variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"622\" width=\"852\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/data-layer-variable-1.jpg#ZgotmplZ\" alt=\"Data Layer Variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Data Layer variable<\/strong> is extremely versatile as well. When you create a Data Layer variable, you specify the Data Layer key whose value you want to retrieve. When the variable is resolved, GTM will look for the most recent value for the key in the <a href=\"https:\/\/www.simoahava.com\/analytics\/google-tag-manager-data-model\/\">internal data model<\/a>. For primitive values (Strings, numbers, Booleans, functions), the variable will return whatever was most recently pushed into the key. For plain objects and Arrays, the variable will return the result of a recursive merge, where only shared keys are replaced.<\/p>\n<p>You can use dot notation to access both Data Layer variable keys which have a dot in their name (e.g. <code>gtm.element<\/code>), or to access properties of DOM element objects (e.g. <code>gtm.element.dataset.name<\/code>).<\/p>\n<p>You can use dot notation to access Array members as well. Square notation won\u2019t work, so replace the square notation with dots: <code>products[0].name<\/code> becomes <code>products.0.name<\/code>.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>The value stored in the Data Layer variable whose name you point out in the Data Layer variable Name field. You can also retrieve the value of an object property, if you are sure that the variable holds an object. To access Array members, use dot notation instead of square notation. You can also specify a Default Value which will be returned if no variable with the given name can be found from the Data Layer when the variable is resolved. If you don\u2019t give a default value, the Data Layer variable will return <em>undefined<\/em> in case no variable with the given name is found.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>The Data Layer variable is your best friend when you want to make the most of Auto-Event Tracking. The Built-In variables and the Auto-Event variable types only give you a handful of DOM properties to choose from in the auto-event element. Use the Data Layer variable to traverse the <code>gtm.element<\/code> object as you wish.<\/p>\n<p>Remember to read my two earlier, in-depth articles about the Data Layer:<\/p>\n<h2 id=\"6-javascript-variable\">6. JavaScript Variable<\/h2>\n<div style=\"aspect-ratio: 704 \/ 422;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/javascript-variable-1.jpg\" title=\"JavaScript variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"422\" width=\"704\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/javascript-variable-1.jpg#ZgotmplZ\" alt=\"JavaScript variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>JavaScript<\/strong> variable returns the value stored in the global JavaScript variable you specify. Note, this is NOT the same as the Custom JavaScript variable, which is a function declaration.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>The value stored in the global JavaScript variable that you specify. If no such global variable exists, the <em>undefined<\/em> value is returned instead.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>Here\u2019s an example of using the JavaScript variable with a custom tag. In this example, I show you how to fire a single tag multiple times by increasing a global JavaScript variable counter with each iteration, and then fetching the value of this variable in linked tags and variables.<\/p>\n<h2 id=\"7-undefined-value\">7. Undefined Value<\/h2>\n<div style=\"aspect-ratio: 1098 \/ 590;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2019\/02\/undefined-value.jpg\" title=\"Undefined Value variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"590\" width=\"1098\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2019\/02\/undefined-value.jpg#ZgotmplZ\" alt=\"Undefined Value variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Undefined Value<\/strong> variable is extremely simple (so simple, in fact, that I\u2019m wondering why it\u2019s not a Built-in variable). Its sole purpose is to return the JavaScript <code>undefined<\/code> value. So it\u2019s essentially the same as a Custom JavaScript variable with:<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>The variable returns the <code>undefined<\/code> JavaScript value.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>Use it whenever you might want to use the <code>undefined<\/code> value effectively. For example, you might want to use it in a Lookup Table or a RegEx Table, returning <code>undefined<\/code> when you want to ignore the value of the table in some cases (such as if you want to <a href=\"https:\/\/www.simoahava.com\/gtm-tips\/undefined-dimensions-wont-get-sent\/\">drop a Custom Dimension from a hit<\/a>.<\/p>\n<h2 id=\"8-auto-event-variable\">8. Auto-Event Variable<\/h2>\n<div style=\"aspect-ratio: 734 \/ 620;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/auto-event-variable-1.jpg\" title=\"Auto-event variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"620\" width=\"734\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/auto-event-variable-1.jpg#ZgotmplZ\" alt=\"Auto-event variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p><strong>Auto-Event variables<\/strong> are used to access the target element of an <a href=\"https:\/\/www.simoahava.com\/analytics\/auto-event-tracking-gtm-2-0\/\">auto-event action<\/a> (e.g. Click, Error, Form Submit). When you create a new Auto-Event variable, you need to specify just which component of the target element you want to access.<\/p>\n<p><strong>Element<\/strong> &#8211; Accesses the DOM Element itself that was the target of the auto-event action. This element is stored under the key <code>gtm.element<\/code> in the Data Layer, and you can create your own, customized auto-event variables using the Data Layer variable, and traversing the <code>gtm.element<\/code> object as you would any other DOM element. For example, to get the value stored in the ID attribute of the auto-event element\u2019s parent, you\u2019d create a Data Layer variable which points to <code>gtm.element.parentElement.id<\/code>. <strong>Note<\/strong>: There are Built-In variables for this (Click Element and Form Element).<\/p>\n<p><strong>Element Classes<\/strong> &#8211; Returns the value of the <code>class<\/code> attribute of the auto-event element. Stored in the Data Layer under the key <code>gtm.elementClasses<\/code>. <strong>Note<\/strong>: There are Built-In variables for this (Click Class and Form Class).<\/p>\n<p><strong>Element ID<\/strong> &#8211; Returns the value of the <code>id<\/code> attribute of the auto-event element. Stored in the Data Layer under the key <code>gtm.elementId<\/code>. <strong>Note<\/strong>: There are Built-In variables for this (Click ID and Form ID).<\/p>\n<p><strong>Element Target<\/strong> &#8211; Returns the value of the <code>target<\/code> attribute of the auto-event element. Stored in the Data Layer under the key <code>gtm.elementTarget<\/code>. <strong>Note<\/strong>: There are Built-In variables for this (Click Target and Form Target).<\/p>\n<p><strong>Element Text<\/strong> &#8211; Returns the value of either the <code>textContent<\/code> or <code>innerText<\/code> property of the auto-event element. The return value is trimmed of whitespace and normalized to account for differences in how browsers interpret element text. <strong>Note<\/strong>: There are Built-In variables for this (Click Text and Form Text).<\/p>\n<p><strong>Element URL<\/strong> &#8211; Returns the value of either the <code>href<\/code> or the <code>action<\/code> attribute of the auto-event element. You can further specify just which URL component you want to access (see the section for the URL variable type for more information). Stored in the Data Layer under the key <code>gtm.elementUrl<\/code>. <strong>Note<\/strong>: There are Built-In variables for this (Click URL and Form URL).<\/p>\n<p><strong>History New URL Fragment<\/strong> &#8211; Returns the new URL fragment set with a browser history event. Stored in Data Layer under the key <em>gtm.newUrlFragment<\/em>. <strong>Note<\/strong>: There is a Built-In variable for this (New History Fragment).<\/p>\n<p><strong>History Old URL Fragment<\/strong> &#8211; Returns the old URL fragment replaced in the browser history event. Stored in Data Layer under the key <em>gtm.oldUrlFragment<\/em>. <strong>Note<\/strong>: There is a Built-In variable for this (Old History Fragment).<\/p>\n<p><strong>History New State<\/strong> &#8211; Returns the new state object set with a browser history event. Stored in Data Layer under the key <em>gtm.newHistoryState<\/em>. <strong>Note<\/strong>: There is a Built-In variable for this (New History State).<\/p>\n<p><strong>History Old State<\/strong> &#8211; Returns the old state object replaced in the browser history event. Stored in Data Layer under the key <em>gtm.oldHistoryState<\/em>. <strong>Note<\/strong>: There is a Built-In variable for this (Old History State).<\/p>\n<p><strong>History Change Source<\/strong> &#8211; Returns a string denoting the event that triggered the history change event (<em>popstate<\/em>, <em>pushState<\/em>, <em>replaceState<\/em>, or <em>polling<\/em>). Stored in Data Layer under the key <em>gtm.historyChangeSource<\/em>. <strong>Note<\/strong>: There is a Built-In variable for this (History Source).<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>The Auto-Event variable returns the value appropriate for the selected element type. If no relevant auto-event has been registered, the variable returns the <em>Default Value<\/em> (if set), or <em>undefined<\/em>.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>There are <em>many<\/em> use cases for the Auto-Event variable. To get you started, I suggest you take a look at the following articles:<\/p>\n<h2 id=\"9-dom-element\">9. DOM Element<\/h2>\n<div style=\"aspect-ratio: 740 \/ 682;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/dom-element-1.jpg\" title=\"DOM Element variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"682\" width=\"740\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/dom-element-1.jpg#ZgotmplZ\" alt=\"DOM Element variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>You can use the <strong>DOM Element<\/strong> variable to retrieve the text content of any given DOM Element. You can also use it to retrieve the value of any attribute of the DOM Element.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>The text content of the given DOM Element, or the value of the given attribute (optional). If no DOM Element with the given ID or CSS selector is found, the variable returns the <em>null<\/em> value.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>You can use this to access any arbitrary DOM Element on the page. This becomes useful if you want to fire an event only if a certain element is on the page.<\/p>\n<h2 id=\"10-element-visibility\">10. Element Visibility<\/h2>\n<div style=\"aspect-ratio: 414 \/ 461;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/element-visibility-variable.jpg\" title=\"Element Visibility variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"461\" width=\"414\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/element-visibility-variable.jpg#ZgotmplZ\" alt=\"Element Visibility variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Element Visibility<\/strong> variable lets you know if any particular element was <a href=\"https:\/\/www.simoahava.com\/analytics\/element-visibility-trigger-google-tag-manager\/\"><em>visible<\/em><\/a> in the browser viewport when the trigger fired. Visibility requires that the element be positioned above the fold of the page in the active browser tab. In other words, the element must actually be <em>in sight<\/em> of the user. The only exception is if there is some other window in front of the browser window where the element is otherwise visible. In this case, GTM would consider the element to still be visible, even though it\u2019s not technically viewable by the user.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>The variable returns either True \/ False indicating if the element was visible or not, respectively, or a percentage of how much of the element was visible when the variable was resolved. You can choose which output type to use in the settings of the variable.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>You can set the visibility variable to check an element with CSS selector <code>body<\/code>, and minimum 1 percent visible. This variable would then tell you if the page was visible in the viewport when the variable was called.<\/p>\n<h2 id=\"11-constant\">11. Constant<\/h2>\n<div style=\"aspect-ratio: 718 \/ 428;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/constant-variable.jpg\" title=\"Constant variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"428\" width=\"718\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/constant-variable.jpg#ZgotmplZ\" alt=\"Constant variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Constant<\/strong> variable is a prime example of how variables are reusable. If you have any string of characters that you need to use often, or which you might need to update in the future, it\u2019s best to store it as a Constant variable instead.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>The Constant variable returns the <em>string<\/em> you choose to type in the Value field.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>The obvious use case is your Google Analytics web property ID. By storing the UA-XXXXX-X code in the Constant variable, you won\u2019t need to look it up every single time you create a new GA tag.<\/p>\n<h2 id=\"12-custom-event\">12. Custom Event<\/h2>\n<div style=\"aspect-ratio: 464 \/ 344;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/custom-event-1.jpg\" title=\"Custom Event variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"344\" width=\"464\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/custom-event-1.jpg#ZgotmplZ\" alt=\"Custom Event variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Custom Event<\/strong> variable returns the value of the \u2018event\u2019 key in the Data Layer. For example, if you run the following code: <code>dataLayer.push({'event' : 'thisEvent'});<\/code>, then the Custom Event variable would hold the value \u2018thisEvent\u2019 after the push. <strong>Note<\/strong>: There is a Built-In variable for this (Event).<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>The value stored in the \u2018event\u2019 key in the Data Layer.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>Honestly, I can\u2019t figure out what this variable is for. If I had to guess, it\u2019s a remnant of the old GTM, where you could accidentally delete the <em>{{event}}<\/em> macro and then use the Custom Event macro to bring it back. In the new UI, there\u2019s a Built-In variable for Event, and at the time of writing there\u2019s also the internal variable _<em>event<\/em> which you can\u2019t delete or deactivate. So there really is no need to create a new Custom Event variable.<\/p>\n<h2 id=\"13-environment-name\">13. Environment Name<\/h2>\n<div style=\"aspect-ratio: 586 \/ 338;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/environment-name.jpg\" title=\"Environment Name\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"338\" width=\"586\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/environment-name.jpg#ZgotmplZ\" alt=\"Environment Name\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Environment Name<\/strong> variable is similar to Custom Event in that it doesn\u2019t really add anything to GTM. There already is a Built-In variable for \u201cEnvironment Name\u201d, which you should use instead of creating this User-Defined variable.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p><em>String<\/em> with the current <a href=\"https:\/\/www.simoahava.com\/analytics\/better-qa-with-google-tag-manager-environments\/\">environment<\/a> name if using an environment snippet, or the draft version identifier if in Preview mode. It won\u2019t return anything for Live or Latest versions.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>Use it to fire tags only if in a certain environment. Remember to read my <a href=\"https:\/\/www.simoahava.com\/analytics\/better-qa-with-google-tag-manager-environments\/\">Environment Guide<\/a> while you\u2019re at it!<\/p>\n<h2 id=\"14-google-analytics-settings\">14. Google Analytics Settings<\/h2>\n<div style=\"aspect-ratio: 1770 \/ 1000;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/google-analytics-settings.jpg\" title=\"Google Analytics Settings variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"1000\" width=\"1770\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/google-analytics-settings.jpg#ZgotmplZ\" alt=\"Google Analytics Settings variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Google Analytics Settings<\/strong> variable returns a set of Universal Analytics tag settings. This can be used to configure multiple tags at once, consolidating their Custom Dimensions and Fields to set, for example.<\/p>\n<p>Note that the Google Analytics Settings variable can only be used in a Universal Analytics tag. You can\u2019t invoke the variable in other contexts.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>A configuration of Google Analytics Settings to be used in a Universal Analytics tag.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>Use the Google Analytics Settings variable to consolidate tag settings across your Universal Analytics tags. For inspiration, read <a href=\"https:\/\/www.simoahava.com\/analytics\/google-analytics-settings-variable-in-gtm\/\">this article<\/a>.<\/p>\n<h2 id=\"15-lookup-table\">15. Lookup Table<\/h2>\n<div style=\"aspect-ratio: 1776 \/ 862;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/lookup-table-variable-1.jpg\" title=\"Lookup Table variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"862\" width=\"1776\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/lookup-table-variable-1.jpg#ZgotmplZ\" alt=\"Lookup Table variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Lookup Table<\/strong> variable performs any number of lookups that you specify, returning the value of the first match. Since this is a <em>Lookup Table<\/em>, the value lookup is always exact match and case-sensitive. You can create your own, <a href=\"https:\/\/www.simoahava.com\/analytics\/simple-regex-lookup-table-for-google-tag-manager\/\">custom Lookup Table<\/a> if this is too strict for you.<\/p>\n<p>The <em>Input variable<\/em> specifies the variable which will be used as the input in the lookups. On each row that you add to the table, you give an output value to be returned by the variable, if the input variable is matched with the Input field value of the row. You can <a href=\"https:\/\/www.simoahava.com\/gtm-tips\/chain-macros-lookup-tables\/\">chain Lookup Tables<\/a> together, creating a powerful, efficient, and flexible value lookup for your tags and variables.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>The value in the Output field of the first row that is matched against the Input variable. You can also give a <em>Default Value<\/em> which will be returned if no match is made. If you don\u2019t specify a <em>Default Value<\/em>, the variable will return the <em>undefined<\/em> value if no match is made.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>Take a look at my original article for some ideas:<\/p>\n<p>Bounteous has also a <a href=\"https:\/\/www.bounteous.com\/insights\/2014\/11\/20\/gtm-lookup-table-upload\/\">really interesting guide<\/a> on automating the Lookup Table variable creation process.<\/p>\n<h2 id=\"16-random-number\">16. Random Number<\/h2>\n<div style=\"aspect-ratio: 652 \/ 338;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/random-number.jpg\" title=\"Random Number\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"338\" width=\"652\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/random-number.jpg#ZgotmplZ\" alt=\"Random Number\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Random Number<\/strong> variable returns a random number between 0 and 2147483647. <strong>Note<\/strong>: There is a Built-In variable for this (Random Number).<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>A number, randomized between 0 and 2147483647.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>You can use the Random Number variable to <a href=\"https:\/\/www.simoahava.com\/analytics\/macro-magic-google-tag-manager\/\">sample your visitors<\/a>.<\/p>\n<h2 id=\"17-regex-table\">17. RegEx Table<\/h2>\n<div style=\"aspect-ratio: 891 \/ 558;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/regex-table-variable.jpg\" title=\"RegEx Table variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"558\" width=\"891\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/regex-table-variable.jpg#ZgotmplZ\" alt=\"RegEx Table variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>RegEx Table<\/strong> variable lets you create a pattern-matching table. It functions similarly to the Lookup Table, with the obvious difference that lookups are exact match only, whereas regular expressions are far more flexible in what you can match against. There are some other additional features in the RegEx Table, which you can read about <a href=\"https:\/\/www.simoahava.com\/analytics\/the-regex-table-variable-in-google-tag-manager\/\">here<\/a>.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>Whatever you have defined in each individual Output field, and the Default Value field.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>You can use the RegEx Table with a Just Links trigger to determine what type of link was clicked. See the screenshot above for hints how to do this.<\/p>\n<h2 id=\"18-container-id\">18. Container ID<\/h2>\n<div style=\"aspect-ratio: 562 \/ 332;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/container-id.jpg\" title=\"container id\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"332\" width=\"562\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/container-id.jpg#ZgotmplZ\" alt=\"container id\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>This is also a <strong>Built-In variable<\/strong>, so use that instead of creating a new User-Defined variable.<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p>The public ID (GTM-XXXXXX) of the Container.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>This is important in <a href=\"https:\/\/www.simoahava.com\/analytics\/understanding-tag-sequencing-in-google-tag-manager\/\">tag sequencing<\/a>, as it\u2019s used to signal when a Custom HTML tag has finished completion. You should also send the Container ID as a Custom Dimension in your GTM hits &#8211; that way you can see in Google Analytics which hits were sent from which container.<\/p>\n<h2 id=\"19-container-version-number\">19. Container Version Number<\/h2>\n<div style=\"aspect-ratio: 644 \/ 318;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/container-version-number-1.jpg\" title=\"Container Version Number\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"318\" width=\"644\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/container-version-number-1.jpg#ZgotmplZ\" alt=\"Container Version Number\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>This is pretty self-explanatory. The <strong>Container Version Number<\/strong> returns the version number of the container that is implemented on the site, or QUICK_PREVIEW if you are previewing the workspace draft.<br \/>\n<strong>Note<\/strong>: There is a Built-In variable for this (Container Version).<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p><em>String<\/em> with the current GTM Container version number, or <em>QUICK_PREVIEW<\/em>, if the workspace draft is in preview mode.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>Assign a Google Analytics Custom Dimension for the container version ID, which will help you analyze the impact of changes various versions of the GTM container have had. This is a great way to debug your GTM and GA implementations.<\/p>\n<h2 id=\"20-debug-mode\">20. Debug Mode<\/h2>\n<div style=\"aspect-ratio: 596 \/ 356;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/01\/debug-mode-1.jpg\" title=\"Debug Mode variable\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"356\" width=\"596\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/01\/debug-mode-1.jpg#ZgotmplZ\" alt=\"Debug Mode variable\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Debug Mode<\/strong> variable returns <code>true<\/code> if the user is viewing the container in Preview mode, and <code>false<\/code> if not. <strong>Note<\/strong>: There is a Built-In variable for this (Debug Mode).<\/p>\n<p><strong>RETURNS<\/strong><\/p>\n<p><em>true<\/em> when the user is in Container Debug mode, and <em>false<\/em> when not.<\/p>\n<p><strong>USE CASE(S)<\/strong><\/p>\n<p>With the Lookup Table variable, you can collect all your GA hits in Debug mode to a separate, test property. Read about this idea in my <a href=\"https:\/\/www.simoahava.com\/analytics\/macro-magic-google-tag-manager\/\">Macro Magic<\/a> article.<\/p>\n<p>You can also send the Debug Mode value as a Custom Dimension, if you want to collect all hits to the same GA property. This way you can filter with the Custom Dimension and collect all your debug hits to a separate Google Analytics profile.<\/p>\n<h2 id=\"summary\">Summary<\/h2>\n<p>I\u2019m bold enough to claim that once you understand variables, you can call yourself a Google Tag Master. It\u2019s not just what the different variable types are. It\u2019s how you use them together to create sense out of the complexity that almost any tag implementation brings in its wake.<\/p>\n<p>Just remember to pay heed to the technical details as well. If you don\u2019t understand the process of how variables are resolved, you\u2019ll often run into unexpected situations. Most often it\u2019s a \u2018race condition\u2019, where the variable is trying to access some other data source which isn\u2019t ready yet.<\/p>\n<p>Be respectful of the \u2018no side effects\u2019 rule as well. Do not use variables for anything else except to build a well-formed <code>return<\/code> statement. If you feel like you need to increase the complexity of your function calls, use a Custom HTML tag instead.<\/p>\n<p>Were you interested in some other aspect of variables that I didn\u2019t cover here? Or do you have a great use case in mind for some variable type? Sound off in the comments, thanks!<\/p>\n<\/p><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>(Updated 21 February 2019) The current version of Google Tag Manager was released in October 2014. With the release, we saw a brand-spanking new UI, a lot of new functionalities (revamped auto-event tracking, for example), plus a new terminology to cope with. We moved away from the programming-centric concepts of Macros and Rules to the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":153226,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[1531,2059,14495,1791,15112],"dealstore":[],"offerexpiration":[],"class_list":["post-153225","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-google","tag-guide","tag-manager","tag-tag","tag-variable"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Variable Guide For Google Tag Manager - Som2ny Network<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fivemor.com\/?p=153225\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Variable Guide For Google Tag Manager - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"(Updated 21 February 2019) The current version of Google Tag Manager was released in October 2014. With the release, we saw a brand-spanking new UI, a lot of new functionalities (revamped auto-event tracking, for example), plus a new terminology to cope with. We moved away from the programming-centric concepts of Macros and Rules to the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=153225\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-24T07:33:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/variable-guide.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1246\" \/>\n\t<meta property=\"og:image:height\" content=\"562\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"32 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=153225#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=153225\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"Variable Guide For Google Tag Manager\",\"datePublished\":\"2025-03-24T07:33:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=153225\"},\"wordCount\":6163,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=153225#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/variable-guide.jpg\",\"keywords\":[\"Google\",\"Guide\",\"Manager\",\"TAG\",\"variable\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=153225#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=153225\",\"url\":\"https:\/\/fivemor.com\/?p=153225\",\"name\":\"Variable Guide For Google Tag Manager - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=153225#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=153225#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/variable-guide.jpg\",\"datePublished\":\"2025-03-24T07:33:18+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=153225#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=153225\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=153225#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/variable-guide.jpg\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/variable-guide.jpg\",\"width\":1246,\"height\":562},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=153225#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Variable Guide For Google Tag Manager\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fivemor.com\/#website\",\"url\":\"https:\/\/fivemor.com\/\",\"name\":\"Som2ny Network\",\"description\":\"Daily Deals\",\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fivemor.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/fivemor.com\/#organization\",\"name\":\"Som2ny Network\",\"url\":\"https:\/\/fivemor.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"width\":300,\"height\":86,\"caption\":\"Som2ny Network\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/fivemor.com\"],\"url\":\"https:\/\/fivemor.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Variable Guide For Google Tag Manager - Som2ny Network","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fivemor.com\/?p=153225","og_locale":"en_US","og_type":"article","og_title":"Variable Guide For Google Tag Manager - Som2ny Network","og_description":"(Updated 21 February 2019) The current version of Google Tag Manager was released in October 2014. With the release, we saw a brand-spanking new UI, a lot of new functionalities (revamped auto-event tracking, for example), plus a new terminology to cope with. We moved away from the programming-centric concepts of Macros and Rules to the [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=153225","og_site_name":"Som2ny Network","article_published_time":"2025-03-24T07:33:18+00:00","og_image":[{"width":1246,"height":562,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/variable-guide.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"32 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=153225#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=153225"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"Variable Guide For Google Tag Manager","datePublished":"2025-03-24T07:33:18+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=153225"},"wordCount":6163,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=153225#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/variable-guide.jpg","keywords":["Google","Guide","Manager","TAG","variable"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=153225#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=153225","url":"https:\/\/fivemor.com\/?p=153225","name":"Variable Guide For Google Tag Manager - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=153225#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=153225#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/variable-guide.jpg","datePublished":"2025-03-24T07:33:18+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=153225#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=153225"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=153225#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/variable-guide.jpg","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/variable-guide.jpg","width":1246,"height":562},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=153225#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"Variable Guide For Google Tag Manager"}]},{"@type":"WebSite","@id":"https:\/\/fivemor.com\/#website","url":"https:\/\/fivemor.com\/","name":"Som2ny Network","description":"Daily Deals","publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fivemor.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fivemor.com\/#organization","name":"Som2ny Network","url":"https:\/\/fivemor.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","width":300,"height":86,"caption":"Som2ny Network"},"image":{"@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","caption":"admin"},"sameAs":["https:\/\/fivemor.com"],"url":"https:\/\/fivemor.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/153225","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=153225"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/153225\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/153226"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=153225"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=153225"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=153225"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=153225"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=153225"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}