{"id":145487,"date":"2025-03-20T10:21:46","date_gmt":"2025-03-20T10:21:46","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/gtmtips-remember-to-flush-unused-data-layer-variables\/"},"modified":"2025-03-20T10:21:46","modified_gmt":"2025-03-20T10:21:46","slug":"gtmtips-remember-to-flush-unused-data-layer-variables","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=145487","title":{"rendered":"#GTMTips: Remember To Flush Unused Data Layer Variables"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<p>Here\u2019s a tip that\u2019s especially important to anyone working with a single-page application. <a href=\"https:\/\/tagmanager.google.com\">Google Tag Manager<\/a> <em>persists<\/em> items in its <a href=\"https:\/\/www.simoahava.com\/analytics\/google-tag-manager-data-model\/\">data model<\/a> until you either manually delete the variable and\/or its value from the data model, or until the user browses away from the page. There\u2019s nothing as annoying as the example in the image below, where a value that was set for an earlier Tag is resent with a new Tag, even though the purpose was to leave it out.<\/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=\"tip-26-flush-unused-data-layer-variables\">Tip 26: Flush unused Data Layer Variables<\/h2>\n<div style=\"aspect-ratio: 960 \/ 540;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2015\/06\/flush-unused-datalayer-variables.jpg\" title=\"Remember to flush unused data layer variables\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"540\" width=\"960\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2015\/06\/flush-unused-datalayer-variables.jpg#ZgotmplZ\" alt=\"Remember to flush unused data layer variables\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>Let\u2019s extend the example in the image above. Say you have a Google Analytics Event Tag, which fires on the <code>makeMoney<\/code> Custom Event Trigger, and has the following Tag settings:<\/p>\n<p><strong>Event Category:<\/strong> Make Money<br \/><strong>Event Action:<\/strong> {{DLV &#8211; userId}}<br \/><strong>Event Label:<\/strong> {{DLV &#8211; criminalStatus}}<br \/><strong>Event Value:<\/strong> {{DLV &#8211; howMuch}}<\/p>\n<p>As you can see, the naming convention I use for the Variables is pretty self-explanatory. It\u2019s just the variable name in the Data Layer prefixed by \u201cDLV &#8211; \u201c.<\/p>\n<p>So, this Tag fires when the first payload is pushed. It gets the following values:<\/p>\n<p><strong>Event Category:<\/strong> Make Money<br \/><strong>Event Action:<\/strong> abcb-1234<br \/><strong>Event Label:<\/strong> true<br \/><strong>Event Value:<\/strong> 10000<\/p>\n<p>This Event signifies that a user with ID \u201cabcb-1234\u201d has scored 10000 dollars in a nefarious scheme, and this event is thus labelled as a criminal act. I will send this information to the proper authorities, after first taking my cut.<\/p>\n<p>Next, the same person, on the same page, decides to make amends and scores a far more appropriate amount of cash in this cyber-scam:<\/p>\n<p><strong>Event Category:<\/strong> Make Money<br \/><strong>Event Action:<\/strong> ddff-2211<br \/><strong>Event Label:<\/strong> true<br \/><strong>Event Value:<\/strong> 2000<\/p>\n<p>But what\u2019s that? Criminal status is still <strong>true<\/strong>?! But you left it out of the <code>dataLayer.push()<\/code>, why would it still be there? Shouldn\u2019t it be empty? Is there no way for this vigilante to escape the searchlights of the police helicopter patrolling the abandoned brick factory?<\/p>\n<p>You see, because there was no reload, the value of the <code>criminalStatus<\/code> variable in GTM\u2019s data model remains <strong>true<\/strong> until overwritten, or until a page (re)load is executed.<\/p>\n<p>This is why the following bit is important. Whenever you push a payload to <code>dataLayer<\/code> that makes a Tag Trigger, make sure you\u2019ve accounted for <strong>any other Data Layer Variables the Tag might use<\/strong>. In the example we\u2019ve used until now, if you want to make sure that <code>criminalStatus<\/code> is flushed for the second push, you would use the following syntax in the push:<\/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\">dataLayer.push({\n  <span style=\"color:#a50\">'event'<\/span> : <span style=\"color:#a50\">'makeMoney'<\/span>,\n  <span style=\"color:#a50\">'howMuch'<\/span> : <span style=\"color:#a50\">'2000'<\/span>,\n  <span style=\"color:#a50\">'userId'<\/span> : <span style=\"color:#a50\">'ddff-2211'<\/span>,\n  <span style=\"color:#a50\">'criminalStatus'<\/span> : <span style=\"color:#00a\">undefined<\/span>\n});\n<\/code><\/pre>\n<\/div>\n<p>This stores the value <code>undefined<\/code> for the variable <code>criminalStatus<\/code>, effectively making it so that the variable does not resolve, dropping the parameter from the Google Analytics hit entirely.<\/p>\n<p>So remember to flush those unused variables!<\/p>\n<p>One other thing. You might be concerned that when using <strong>Enhanced Ecommerce<\/strong>, this means that your impressions (which you send with the Page View Tag, right?) will be sent with every single other Enhanced Ecommerce hit on the page as well. Worry not! Enhanced Ecommerce is special. It leverages an older version of GTM\u2019s data model, where objects are not merged together. With <a href=\"https:\/\/www.simoahava.com\/analytics\/ecommerce-tips-google-tag-manager\/\">Enhanced Ecommerce<\/a>, only the most recent hit is ever processed by your Tags.<\/p>\n<p>That\u2019s it. Go enjoy the summer!<\/p>\n<\/p><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Here\u2019s a tip that\u2019s especially important to anyone working with a single-page application. Google Tag Manager persists items in its data model until you either manually delete the variable and\/or its value from the data model, or until the user browses away from the page. There\u2019s nothing as annoying as the example in the image [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":145488,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[11603,56503,14492,564,7762,9939,30217],"dealstore":[],"offerexpiration":[],"class_list":["post-145487","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-data","tag-flush","tag-gtmtips","tag-layer","tag-remember","tag-unused","tag-variables"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>#GTMTips: Remember To Flush Unused Data Layer Variables - 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=145487\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"#GTMTips: Remember To Flush Unused Data Layer Variables - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"Here\u2019s a tip that\u2019s especially important to anyone working with a single-page application. Google Tag Manager persists items in its data model until you either manually delete the variable and\/or its value from the data model, or until the user browses away from the page. There\u2019s nothing as annoying as the example in the image [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=145487\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-20T10:21:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/flush-unused-datalayer-variables.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"540\" \/>\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=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=145487#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=145487\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"#GTMTips: Remember To Flush Unused Data Layer Variables\",\"datePublished\":\"2025-03-20T10:21:46+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=145487\"},\"wordCount\":562,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=145487#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/flush-unused-datalayer-variables.jpg\",\"keywords\":[\"Data\",\"Flush\",\"GTMTips\",\"Layer\",\"Remember\",\"Unused\",\"Variables\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=145487#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=145487\",\"url\":\"https:\/\/fivemor.com\/?p=145487\",\"name\":\"#GTMTips: Remember To Flush Unused Data Layer Variables - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=145487#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=145487#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/flush-unused-datalayer-variables.jpg\",\"datePublished\":\"2025-03-20T10:21:46+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=145487#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=145487\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=145487#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/flush-unused-datalayer-variables.jpg\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/flush-unused-datalayer-variables.jpg\",\"width\":960,\"height\":540},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=145487#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"#GTMTips: Remember To Flush Unused Data Layer Variables\"}]},{\"@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":"#GTMTips: Remember To Flush Unused Data Layer Variables - 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=145487","og_locale":"en_US","og_type":"article","og_title":"#GTMTips: Remember To Flush Unused Data Layer Variables - Som2ny Network","og_description":"Here\u2019s a tip that\u2019s especially important to anyone working with a single-page application. Google Tag Manager persists items in its data model until you either manually delete the variable and\/or its value from the data model, or until the user browses away from the page. There\u2019s nothing as annoying as the example in the image [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=145487","og_site_name":"Som2ny Network","article_published_time":"2025-03-20T10:21:46+00:00","og_image":[{"width":960,"height":540,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/flush-unused-datalayer-variables.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=145487#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=145487"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"#GTMTips: Remember To Flush Unused Data Layer Variables","datePublished":"2025-03-20T10:21:46+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=145487"},"wordCount":562,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=145487#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/flush-unused-datalayer-variables.jpg","keywords":["Data","Flush","GTMTips","Layer","Remember","Unused","Variables"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=145487#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=145487","url":"https:\/\/fivemor.com\/?p=145487","name":"#GTMTips: Remember To Flush Unused Data Layer Variables - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=145487#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=145487#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/flush-unused-datalayer-variables.jpg","datePublished":"2025-03-20T10:21:46+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=145487#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=145487"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=145487#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/flush-unused-datalayer-variables.jpg","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/flush-unused-datalayer-variables.jpg","width":960,"height":540},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=145487#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"#GTMTips: Remember To Flush Unused Data Layer Variables"}]},{"@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\/145487","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=145487"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/145487\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/145488"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=145487"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=145487"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=145487"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=145487"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=145487"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}