Google Tag Manager not firing purchase event (Shopify)

Viewed 694

I've recently been going a GTM setup on Shopify and all has been going well apart from the purchase tracking. I'm finding that every other event tracks perfectly in GAUA, GA4 and Google Ads (Add to carts, initiate checkouts, etc) but whenever somebody completes a transaction there's no record of it.

I've done testing myself by firing purchases in different ways:

  • With and without cookies
  • Through GTM debugger
  • On mobile data
  • In incognito

and every single time my own purchases track and the Datalayer fires & fills perfectly. However it seems whenever there's a real customer order it doesn't track. I can see that the GTM container must be active, as in GAUA I can see that they have landed on the order confirmation page at the end of their journey, it just seems as though the datalayer never fills.

Here's my DataLayer code that is in Shopify's additional checkout scripts (not a plus store):

 <script>
{% if first_time_accessed %}
  window.dataLayer = window.dataLayer || [];     
  window.dataLayer.push({ ecommerce: null });  
  window.dataLayer.push({                      
    'event': 'EEPurchase',
    'pagePath': '/checkout/thank_you',
    'pageTitle': 'Purchase',
    'ecommerce':{
      'purchase':{
        'actionField':{
          'id': '{{order.name}}',
          'revenue': {{ order.total_price | money_without_currency | replace: ",", "" }},     
          'tax': {{order.tax_price | money | money_without_currency | replace: ",", "" }},       
          'shipping': {{order.shipping_price | money_without_currency | replace: ",", "" }},    
          'coupon': [
          {% for discount_application in order.cart_level_discount_applications %}
          {
            '{{ discount_application.title }}'
          },
          {% endfor %}
          ]
        },
        'products':[
        {% for line_item in line_items %}
        {
          'name': '{{line_item.title}}',
          'id': '{{line_item.product_id}}',
          'price':{{line_item.original_price | money_without_currency | replace: ",", ""  }},
          'brand': '{{line_item.vendor}}',
          'category': '{{line_item.product.type}}',
          {% unless line_item.variant.title == 'Default Title' %}'variant': '{{line_item.variant.title}}', {% endunless%}
          'quantity': {{line_item.quantity}}
        },
        {% endfor %}
        ]
      }
    }
  })
{% endif %}
</script>

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-TRACKING-CODE');</script>
<!-- End Google Tag Manager -->

Any insight is appreciated, thanks!

0 Answers
Related