{"id":68290,"date":"2025-02-04T18:55:45","date_gmt":"2025-02-04T18:55:45","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/data-layer-picker-custom-variable-template\/"},"modified":"2025-02-04T18:55:45","modified_gmt":"2025-02-04T18:55:45","slug":"data-layer-picker-custom-variable-template","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=68290","title":{"rendered":"Data Layer Picker &#8211; Custom Variable Template"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<div style=\"aspect-ratio: 1800 \/ 942;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2021\/02\/data-layer-picker.jpg\" title=\"data-layer-picker.jpg\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"942\" width=\"1800\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2021\/02\/data-layer-picker.jpg#ZgotmplZ\" alt=\"data-layer-picker.jpg\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>The <strong>Data Layer Picker<\/strong> <a href=\"https:\/\/www.simoahava.com\/analytics\/custom-templates-guide-for-google-tag-manager\/\">custom variable template<\/a> is a variable template for <a href=\"https:\/\/tagmanager.google.com\/\">Google Tag Manager\u2019s<\/a> <a href=\"https:\/\/tagmanager.google.com\/gallery\/\">community template gallery<\/a>.<\/p>\n<h3 id=\"description\">Description<\/h3>\n<p>The Data Layer Picker variable allows you to <strong>access keys and values<\/strong> in the <code>dataLayer.push()<\/code> that caused the tag to fire for which the variable is evaluated.<\/p>\n<p>This is different to how the Data Layer Variable works, as the DLV doesn\u2019t care (or remember) in what <code>push()<\/code> the key was added to GTM. Instead, it merges everything together into its data model.<\/p>\n<p>With Data Layer Picker, however, you can access the exact contents of the object that was pushed into <code>dataLayer<\/code>.<\/p>\n<p>There are many use cases for this, such as the need to access a specific <em>state<\/em> of the <code>dataLayer<\/code> message prior to it being merged with the other keys in GTM\u2019s data model.<\/p>\n<p>To use the variable, you have two options. Either you retrieve the <strong>Entire object<\/strong> that was pushed into <code>dataLayer<\/code>, or you fetch the value for a <strong>Specific key<\/strong>. You can use <strong>dot notation<\/strong> when specifying the property name.<\/p>\n<p>The template will first try to get the nested structure at the end of the dot notation path (e.g. <code>gtm.elementId<\/code> will look for the value at the end of <code>{gtm: {elementId: 'somevalue'}}<\/code>). If it doesn\u2019t match anything, it will then try to get the value as if the dot notation path were an entire key name in itself (e.g. <code>gtm.elementId<\/code> will look for the value at the end of <code>{'gtm.elementId': 'somevalue'}<\/code>). If no match is made, then <code>undefined<\/code> is returned.<\/p>\n<p>The template also works with objects pushed to <code>dataLayer<\/code> by other custom templates.<\/p>\n<h3 id=\"release-notes\">Release notes<\/h3>\n<table>\n<thead>\n<tr>\n<th>Date<\/th>\n<th>Changeset<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>26 May 2021<\/td>\n<td>Fix issue with undefined objects breaking the variable.<\/td>\n<\/tr>\n<tr>\n<td>26 February 2021<\/td>\n<td>Initial release.<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>The Data Layer Picker custom variable template is a variable template for Google Tag Manager\u2019s community template gallery. Description The Data Layer Picker variable allows you to access keys and values in the dataLayer.push() that caused the tag to fire for which the variable is evaluated. This is different to how the Data Layer Variable [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":68291,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[834,11603,564,36304,4196,15112],"dealstore":[],"offerexpiration":[],"class_list":["post-68290","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-custom","tag-data","tag-layer","tag-picker","tag-template","tag-variable"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Data Layer Picker - Custom Variable Template - 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=68290\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Data Layer Picker - Custom Variable Template - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"The Data Layer Picker custom variable template is a variable template for Google Tag Manager\u2019s community template gallery. Description The Data Layer Picker variable allows you to access keys and values in the dataLayer.push() that caused the tag to fire for which the variable is evaluated. This is different to how the Data Layer Variable [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=68290\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-04T18:55:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/data-layer-picker.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1790\" \/>\n\t<meta property=\"og:image:height\" content=\"944\" \/>\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=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=68290#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=68290\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"Data Layer Picker &#8211; Custom Variable Template\",\"datePublished\":\"2025-02-04T18:55:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=68290\"},\"wordCount\":281,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=68290#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/data-layer-picker.jpg\",\"keywords\":[\"Custom\",\"Data\",\"Layer\",\"Picker\",\"Template\",\"variable\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=68290#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=68290\",\"url\":\"https:\/\/fivemor.com\/?p=68290\",\"name\":\"Data Layer Picker - Custom Variable Template - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=68290#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=68290#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/data-layer-picker.jpg\",\"datePublished\":\"2025-02-04T18:55:45+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=68290#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=68290\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=68290#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/data-layer-picker.jpg\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/data-layer-picker.jpg\",\"width\":1790,\"height\":944},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=68290#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Data Layer Picker &#8211; Custom Variable Template\"}]},{\"@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":"Data Layer Picker - Custom Variable Template - 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=68290","og_locale":"en_US","og_type":"article","og_title":"Data Layer Picker - Custom Variable Template - Som2ny Network","og_description":"The Data Layer Picker custom variable template is a variable template for Google Tag Manager\u2019s community template gallery. Description The Data Layer Picker variable allows you to access keys and values in the dataLayer.push() that caused the tag to fire for which the variable is evaluated. This is different to how the Data Layer Variable [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=68290","og_site_name":"Som2ny Network","article_published_time":"2025-02-04T18:55:45+00:00","og_image":[{"width":1790,"height":944,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/data-layer-picker.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=68290#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=68290"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"Data Layer Picker &#8211; Custom Variable Template","datePublished":"2025-02-04T18:55:45+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=68290"},"wordCount":281,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=68290#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/data-layer-picker.jpg","keywords":["Custom","Data","Layer","Picker","Template","variable"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=68290#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=68290","url":"https:\/\/fivemor.com\/?p=68290","name":"Data Layer Picker - Custom Variable Template - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=68290#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=68290#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/data-layer-picker.jpg","datePublished":"2025-02-04T18:55:45+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=68290#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=68290"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=68290#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/data-layer-picker.jpg","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/data-layer-picker.jpg","width":1790,"height":944},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=68290#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"Data Layer Picker &#8211; Custom Variable Template"}]},{"@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\/68290","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=68290"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/68290\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/68291"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=68290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=68290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=68290"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=68290"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=68290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}