title: Google Tag Manager Data Layer Variable undefined - Shopify
body: <p>I'm using Shopify variables to try and push data through the Data Layer to use in Schema on particular pages. I used a Snippet to do this:</p>
  <pre><code>&lt;!-- GTM Product Information via Data Layer --&gt;
  
  {% if product.url contains 'products' %}
  {%- assign current_variant = product.selected_or_first_available_variant -%}
    &lt;script&gt;
     window.dataLayer = window.dataLayer || [];
     window.dataLayer.push({
        'gtm_product_url': '{{ product.url }}',
        'gtm_product_title' : '{{ product.title }}',
        'gtm_product_image' : '{{ product.featured_image }}',
        'gtm_product_description' : '{{ product.description | strip_html | strip_newlines | replace: '&quot;', '' }}',
        'gtm_date' : '{{'now' | date: '%Y-%m-%d' }}',
        'gtm_sku' : '{{ current_variant.sku }}'
     });
    &lt;/script&gt;
  {% endif %}
  
  
  {% if page.url contains 'pages' %}
    &lt;script&gt;
     window.dataLayer = window.dataLayer || [];
     window.dataLayer.push({
        'gtm_page_title': '{{ page.title }}',
        'gtm_page_published': {{ page.published_at }},
        'gtm_page_image' : {{ page_image | img_url }},
        'gtm_page_description' : {{ page_description }}
     });
    &lt;/script&gt;
  {% endif %}
  </code></pre>
  <p>I added the Variables in Google Tag Manager. The data shows up on the pages just fine (using the Shopify variables). And the product pages are actually pushing the data to GTM.</p>
  <p>My problem is with the 'pages'. I see the data on the pages from Shopify and I've added the Variables into GTM, but they all show undefined when I try to add them to GTM.</p>
  <p>I'm not sure what I'm doing wrong though. Any insights would be greatly appreciated!</p>