Google Analytics 4 (GA4) Integration Idea

I've read all the posts on this forum about Google Analytics 4 and how Shopify doesn't support it yet (because they only accept UA tags).

Some suggested that we can manually install the code into our Shopify theme.liquid file in the HEAD section, but that's only a half solution because unless the tag fires on the Checkout page, you're not getting any conversion data. 

My question... can't we simply paste the entire g.tag tracking code into the Settings --> Checkout --> Additional Scripts section and call it a day?

screenshot-rondeno-culinary-designs.myshopify.com-2020.11.22-11_32_20.png

I understand that you need Shopify Plus to edit the checkout.liquid file, but for the rest of us, aren't we accomplishing the same thing by pasting the following complete script into that Additional Scripts area?

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-TVE9BVKK0C"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-XXXXXXXXXX');
</script>

 

 I just tried this on one of my Shopify sites, so I can't report back whether it tracks conversions, but I will update this thread and let you know. 

Has anyone else tried this on one of their sites and had success?

Join my Shopifreaks Newsletter: www.shopifreaks.com
Learn about affiliate marketing: www.shopaffiliateapps.com
Hire me to help with your store: www.ideasfocused.com

I wish you much success with your Shopify store!
0 Likes
Wiyre
Shopify Partner
3 0 0

This is a clever idea, but unfortunately it will not work. When you click on "Save" in the "Additional Scripts" section, Shopify will remove key parts of the GA4 code which will make the additional code you paste within the "Additional Scripts" section useless. The only way to have Google Analytics 4 support is to modify the theme.liquid file, which you can do by following the instructions outlined within this video (for those who have the ability to edit the theme code). 

0 Likes

@Wiyre if I'm not mistaken though, the video tutorial you referenced also does not include conversion tracking at the Checkout page. So it's ultimately the same issue I was running into earlier where only part of GA4 can be installed. 

Join my Shopifreaks Newsletter: www.shopifreaks.com
Learn about affiliate marketing: www.shopaffiliateapps.com
Hire me to help with your store: www.ideasfocused.com

I wish you much success with your Shopify store!
0 Likes
Wiyre
Shopify Partner
3 0 0

To track with GA4 on the checkout page, you just need to follow the instructions in the video and add the GA4 tracking code to both the theme.liquid and checkout.liquid. Conversion tracking at a more granular level is a bit more complicated, and probably would require you to use some combination of Google Tag Manager + GA4 tracking code. Until Shopify supports GA4 by default (no ETA on this) we are stuck with these types of workarounds. 

0 Likes