Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hello everyone,
I'm running into an issue with a client's Shopify store where our PPC conversion tracking suddenly stopped working and we're not quite sure why. We have a standard installation of Google Ads in the Checkout > Additional scripts section that looks like this:
{% if first_time_accessed %} <!-- Global site tag (gtag.js) - Google Ads: ***** --> <script async src="https://www.googletagmanager.com/gtag/js?id=AW-*****"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-*****'); </script> <!-- Event snippet for Purchase conversion page --> <script> gtag('event', 'conversion', { 'send_to': 'AW-*****/*****', 'value': {{ total_price | money_without_currency }}, 'currency': 'USD', 'transaction_id': '{{order.order_number}}' }); </script> {% endif %}
This is the same installation that we use across a few other stores and works great. It used to work on this storefront too until last week, about the time we switched to a different sales channel (has since been turned off).
During troubleshooting, I checked through the source code and noticed that a bunch of shopify variables now return null. Specifically total_price resolves to null and causes the following Javascript error:
Uncaught SyntaxError: Unexpected token ','
This is what it looks like when I inspect page source.
<!-- Global site tag (gtag.js) - Google Ads: ***** --> <script async src="https://www.googletagmanager.com/gtag/js?id=AW-*****"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-*****'); </script> <!-- Event snippet for Purchase conversion page --> <script> gtag('event', 'conversion', { 'send_to': 'AW-*****/*****', 'value': , 'currency': 'USD', 'transaction_id': '3947' }); </script>
So 'total_price | money_without_currency' is clearly not returning the correct value and this is breaking the javascript. If I output the money as a currency it looks like this:
// This... <script>console.log({{ total_price | json }});</script> // Resolves to this <script>console.log(null);</script>
I've never seen an issue like this where a shopify global variable just doesn't return anything.
I noticed one more strange difference between this store and our other working stores. Between the <head> tags I noticed that Shopify.Checkout.token is also returning null
<script type="text/javascript"> Shopify = window.Shopify || {}; if (window.opener) { window.opener.postMessage(JSON.stringify({"current_checkout_page": null}), "*"); } Shopify.Checkout = Shopify.Checkout || {}; Shopify.Checkout.apiHost = "*****.myshopify.com"; Shopify.Checkout.assetsPath = "\/\/cdn.shopify.com\/s"; Shopify.Checkout.i18n = {"orders":{"order_updates":{"title":"Order updates"}}}; Shopify.Checkout.isOrderStatusPage = true; Shopify.Checkout.token = null; </script>
I'm not sure what the Shopify.Checkout.token is supposed to be, but I just notice that it's defined for our other working storefronts. I've tried everything that I can think of so any and all assistance would be hugely appreciated.
Thank you!
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025