How to Set Up Google Tag Manager in Shopify — in Minutes
Yes, there is a creative way to implement Google Tag Manager on your Shopify store. See how!
Last Updated: May 3, 2019
I’m all about finding creative ways to solve problems. Sometimes this results in my colleagues giving me hell for not doing it the right way.
Consider this tip on how to add Google Tag Manager to your site-wide Shopify store one of those creative solutions.
New: We’ve launched our own app that automates the install of GTM + Data Layer + AdWords!
GTM Suite for Shopify
Install our GTM app that comes with the complete Google dataLayer and pre-built containers.Learn More
I recently went through a Google Analytics audit for a store on Shopify and noticed they were missing custom event actions (other than the default Shopify Event Actions “client_attribute_events”).
Custom event tracking in Google Analytics is an extremely powerful addition to your behaviors analytics analysis. Without event actions tracking your unique onsite marketing techniques you are missing out on a wealth of data that will empower your marketing decisions.
Enter Google Tag Manager — my go-to for adding custom Google Analytics behavior events to enrich my data from a user’s journey to conversion (or exiting 🙁 ).
A quick review of Shopify documentation pointed to a Shopify Plus only feature, whereas a Google Search led me to customizing the liquid theme files.
After doing my own testing and implementation, it turns out there are a few options to add GTM to Shopify and Shopify Plus stores:
- Implement in the Google Analytics admin settings which covers all pages, including checkout and thank you pages
- Implement via theme.liquid file that covers all pages, except checkout and thank you pages
- *New* Implement through our Shopify app in minutes (including all AdWords remarketing tags!)
Option # 1 is my preference for non Shopify Plus stores so I can have GTM on every page, including checkout. Otherwise you can follow instructions below to implement via theme files.
Option # 1: How I added GTM to Shopify Admin
Implement in the Admin
In order to get Google Tag Manager setup across the entire site, including all checkout pages, it only needs to be set up in one place within the Shopify admin.
Step 1. Copy your Universal Google Analytics (GA) script from Google Analytics > Property > Tracking Info > Tracking Code
Step 2. Paste your Google Analytics script into your Shopify Admin > Sales Channels > Online Store > Google Analytics
Step 3. Copy your Google Tag Manager snippet from your GTM admin (NOTE: without the opening and closing <script> </script> tags):
It should end up looking similar to the screenshot:
Just in case you have placed GTM in your Shopify Account > Settings > Checkout settings, you don’t actually need this anymore since the process outlined above will work on all pages, including checkout.
Verify Your Google Tag Manager is Working!
First, I want to make clear that I recommend you keep your sitewide Google Analytics and eCommerce pageview tracking through the native Shopify setup that I outlined in step 1 above.
In many cases it won’t be worth the additional effort to reimplement everything via GTM especially since Enhanced eCommerce is already hooked up for you!
Ok, on to verifying.
Add a new Universal Analytics tag with the Event Track Type with the All Pages trigger:
SAVE this tag.
- Click the big “Preview” button in the top right corner of your GTM Workspace to enable Preview mode
- Go to your website URL. You should see the GTM debug console at the bottom of your browser displaying the tags that have fired successfully like this below:
And you should also see this firing on your checkout pages as well (see how I show how to a/b test Shopify’s checkout here):
You can now begin adding and testing more tags to your container to verify all works as you expect it to.
Do you prefer to install GTM within your Shopify theme?
Option # 2: Implement GTM in Theme Files
This is pretty straight forward and only takes a few steps:
Step 1: Copy your GTM script into your theme.liquid at top of <head>
If you have a developer or agency then ensure you are requesting this to be put near the top of your opening <head>.
Step 2: Copy your GTM noscript into your theme.liquid at top of <body>
That’s it. If you are on Shopify Plus then you’ll need to replicate this step in your checkout.liquid theme file as well.
Option # 3: Implement our Shopify App
After months of helping thousands of Shopify stores implement GTM, we decided to build our own app! Our Shopify app covers the installation of GTM along with all of the dataLayer variables needed for Google AdWords dynamic remarketing.
You can view all of the details on the app here – check it out!
Now that you have GTM loading on your entire Shopify store, how can you take advantage of this?
- Add 3rd party marketing scripts/pixels without the need for a lengthy development process.
- Add Google Analytics custom events that can unlock more even more insights to help in your conversion optimization strategy.
- Utilize GTM for more advanced onsite feature control, clean URL parameter sharing, etc.
Related Shopify “How To’s”:
- GTM Data Layer, Triggers, and Conversion Event Tracking for Shopify
- Implement Google Optimize w/Shopify
- Google Analytics Best Practices for Shopify
GTM Suite for Shopify
Get GTM installed on your store in minutes