Google Tag Manager Ecommerce and Data Layer

Highlighted
New Member
1 0 1

Hi Shopify experts,

I have added the google tag manager to my theme.liquid files and added my google tag manager snippet code and data layer for capturing ecommerce variables to the additional snippets and code section. However, no ecommerce data is flowing into Google Analytics. 

Has anyone had success capturing ecommerce information with Google Tag Manager? Below is the code that I am using. 

<!--DataLayer Code for Ecommerce Tracking-->
<script>
dataLayer = [{
'transactionId': {{ order.name }},
'transactionAffiliation': ‘Butterfly Body Liners',
'transactionTotal': {{ order.total_price | money }} ,
{% for tax_line in tax_lines %}
'transactionTax': {{ tax_line.price | money }} ,
{% endfor %}
'transactionShipping': {{ shipping_method.price | money }} ,
'transactionProducts': [{
{% for line in line_items %}
'sku': {{ line_item.sku }},
'name': {{ line_item.title}},
'price': {{ line_item.price | money }},
'quantity': {{ line_item.quantity }}
{% endfor %}
}]
}];
dataLayer.push({"event": ‘trackTrans’})
</script>
<!--End DataLayer Code for Ecommerce Tracking-->
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXX";
height="0" width="0"
style="display:none;visibility:hidden"></iframe></noscript>
<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=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXX');</script>
<!-- End Google Tag Manager -->

Highlighted
New Member
1 0 0

Hello @Ashley17 

Maybe you have found the answer somewhere else or by your self since the publication.

Could you please share with us what was going wrong?

Thanks

0 Likes