Setting up Google Tag Manager for Shopify is essential to track and manage various tags without constantly tweaking your website's code. Whether you want to monitor site traffic, track conversions, or optimize ads, Google Tag Manager simplifies everything.
Today, we’ll walk you through how to install Google Tag Manager on Shopify, referencing helpful Shopify guides to ensure everything is set up correctly.
What is Google Tag Manager?
Google Tag Manager (GTM) is a free tool that helps you manage and deploy tracking codes (tags) without editing the actual website code. These tags can collect all data, from traffic metrics to purchase conversions.
Shopify and Google Tag Manager are a powerful combination. With GTM, you can:
- Easily manage multiple tags (Google Analytics, Ads, Facebook, etc.) without touching your Shopify code.
- Track your store's performance—purchases, cart actions, Shopify collections, or even product views."
- Set up and optimize your marketing campaigns quickly by linking GTM with Google Ads and Facebook.
How to Install Google Tag Manager on Shopify
There are three easy ways to add Google Tag Manager to Shopify. Each method caters to different levels of technical skills. You can choose one option that is easy for you to do or one that would work in your Shopify account.
Option 1: Install Google Tag Manager Via Shopify’s Google & YouTube App
This is the easiest and quickest way to set up GTM, especially if you're looking to track Google Ads conversions.
Here’s how you can install it:
- In Shopify's admin dashboard, go to the Home page.
- Click Apps.
- Type in Google & YouTube in the search bar.
- Click on the Google & YouTube app when it appears.
- Click Install, then Install again.
- Once installed, Click Connect Google account to connect your Google Ads account and enable conversion tracking.
- Complete the setup by following the on-screen instructions.
Option 2: Install Google Tag Manager Via Shopify’s Google Analytics Settings
If you already have Google Analytics 4 set up for your Shopify store, this is another simple way to connect with GTM.
Follow these steps:
- Click Online Store under Sales Channels in your Shopify admin dashboard.
- Select Preferences.
- Scroll to the Google Analytics section and click Set up Google.
NOTE: If you don't have the Google & YouTube app installed in your Shopify, check the required permissions list and click Install at the bottom to proceed. OR click Connect and select the Google account that owns your Analytics property if the app is not connected to Google.
- In the drop-down list, select your Google tag ID.
- Click Connect your Google Analytics 4property.
Option 3: Install Google Tag Manager Via Shopify Theme Files
If you prefer more control over your GTM setup or you are a web developer, you can manually insert the GTM code into your Shopify theme.
Here’s how to do it:
- Go to Online Store in your Shopify admin dashboard.
- Click Preferences.
- In your active theme, click the three dots beside Customize.
- Select Edit Code.
- Locate the {/}theme.liquid file under the Layout section.
IMPORTANT NOTE: Check the file to ensure that Google tracking tags that look like the below are not there. If it shows up, it means you already installed Google products. You do not need to go over the next steps as it could lead to duplicate tracking, which can give you inaccurate data for page views and conversions that will affect your business strategies.
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'TAG_ID');
</script>
If the code doesn't show up, proceed to the next steps to finish the setup:
- Go to your GTM dashboard.
- Click the GTM ID in blue font beside Workspace Changes.
- Copy the <head> code.
- Paste the code right after the <head> tag in the theme.liquid file.
- Click Save to publish the changes.
It is recommended to implement the Google Tag on every page of your website to measure the entire customer journey. More importantly, you must avoid adding more than one Google Tag on a web page to avoid duplicate conversions now called key events. - https://www.youtube.com/watch?v=RHpP07zREM8
How to Add Google Tag Manager to Shopify for Advanced Tracking
Once you’ve set up GTM on your Shopify store, you can unlock even more functionality by adding advanced tracking tags. Here’s how to add Google Tag Manager to Shopify for more in-depth tracking.
Set Up Conversion Tracking on Shopify
Conversion tracking, including Shopify tracking, is essential to see how many visitors complete actions on your website. Access to this data will help you understand which campaigns are driving conversions, leading to more effective business ideas or decisions about your ad spend and overall strategy.
You can track the following types of actions:
- Website actions like purchases and sign-ups
- Phone calls that come directly from your ads or calls made to a phone number on your site
- App downloads and in-app actions like purchases within your mobile app
- Offline conversions are actions that start online (like filling out a contact form) and are completed offline (like signing a contract in-store)
- Local actions like physical store visits, such as getting directions or calling the store.
IMPORTANT NOTE: If you install GTM through the Google & YouTube app on Shopify or link your Merchant Center and Google Ads accounts, conversion tracking for both Ads and free listings will be automatically configured.
More importantly, you must provide users with clear and comprehensive information about the data you collect and secure their consent for ad personalization as needed by law.
For GTM set up manually, here's how to set up conversion tracking on your Shopify:
- Go to your Google Ads account.
- Click Tools and Settings.
- Select Conversions under Measurement.
- Click the plus (+) sign.
- Choose Website and fill in the details.
- Select Install the tag yourself.
- Copy the Event snippet code.
- Go to your Google Tag Manager account.
- Click Tags and New.
- Click Tag Configuration.
- Select Custom HTML Tag.
- Paste the event snippet into the HTML field.
- Set up a trigger based on specific user actions, such as when a customer reaches the thank-you page after completing a purchase.
- Save the tag.
Install Conversion Tags for Google Ads and Facebook
If you're running Google Ads or Facebook campaigns, adding conversion tags will help you measure your ad performance accurately.
Install Google Ads Conversion Tag
- In your Google Ads dashboard, go to Tools and Settings.
- Create a New Conversion Action and select Website as the conversion type.
- Fill in the details of what you want to track (e.g., purchases, sign-ups).
- Head to GTM and create a new Google Ads Conversion Tracking Tag.
- Fill in the details, which you can obtain from the Google Ads setup.
- Set up a trigger based on user actions (e.g., thank-you page after a purchase).
- Save and test the tag.
Install Meta (Facebook) Pixel Tag
- Go to your Google Tag Manager account.
- Create a new tag.
- Click Tag Configuration and choose Custom HTML.
- Go to your Meta Events Manager.
- Choose Add Event.
- Choose From a New Website.
- Click Install code manually.
- Click Copy Code.
- Go back to your GTM account and paste the code in the HTML field.
- Click the Advanced Settings dropdown.
- In the Tag firing options, select Once per page.
- In Fire On, select All Pages.
- Click Save.
- Create Event-Specific Tags:
- Go to your Google Tag Manager account.
- Create a new tag.
- Click Tag Configuration and choose Custom HTML.
- Copy and paste the event-related code, along with any other variables you want to receive.
- Click the Advanced Settings dropdown.
- In the Tag firing options, select Once per event.
- In the Tag Sequencing, select Fire a tag before [tag name] fires.
- Select your base code tag under Setup tag.
- In Fire On, choose the appropriate trigger for your site.
- Select Create Tag. You can create more tags for the other events on your website (e.g. add to cart)
- Once you've completed creating tags, click Publish.
Custom Event Tracking
Want to track specific actions like a button click or a form submission? Here’s how you can set up custom event tracking in GTM:
- Go to Triggers in GTM and create a New Trigger.
- Select Custom Event.
- Enter an event name.
- Select Use Regex Matching to enable this field to accept regular expressions.
- Click Save.
How to Test Your Google Tag Manager for Shopify
Before launching your store with the new GTM tags, it's important to test them to ensure they’re working properly.
Use Tag Manager Preview Mode
Google Tag Manager’s Preview Mode is a valuable tool that allows you to see how your tags behave on your website in real time, ensuring they trigger correctly when users take specific actions like completing a purchase or signing up.
Here’s how to test your GTM via Tag Manager Preview Mode:
- Open GTM and click on Preview.
- Enter your Shopify store’s URL in the preview window.
- Some websites or pages may be broken if an additional debug parameter is introduced to the URL. If so, uncheck the box labeled Include debug signal in the URL.
- Click Connect.
- Browse your store and monitor whether tags fire as expected.
Use the Google Tag Assistant Tool
Google’s Tag Assistant is another handy tool for verifying and troubleshooting tags. It checks if your Google tags are installed and firing correctly.
Here’s how to use the Google Tag Assistant tool to test GTM:
- Go to your Google Ads account.
- Click Goals.
- Select Conversions.
- Click Summary.
- Check the Status column to see if any of your conversions are marked as Unverified or Tag inactive. The overview statuses are active, needs attention, and not recording.
- Active (Green highlight): Everything is working.
- Needs Attention (Yellow highlight): There are action items or issues to address.
- Not Recording (Red highlight): No ping from your conversion measurement tag in over 24 hours, no measurement platform linked (e.g. Firebase, Google Play), or your account is not allowlisted (e.g. Store Sales and Store Visits).
- In the Actions column, select Troubleshoot.
- Click Get Started to open Tag Assistant in a new window.
- Enter the web page URL.
- Once you've entered the URL, click Connect to open the page in a new browser tab.
- Test your conversion tags(e.g. form admission, checkout).
- Switch back to the Preview window in Tag Manager to confirm if the tags fire at the correct moment.
- Refresh the Conversions page in your Google Ads account. If everything is working correctly, the tracking status should update to No Recent Conversions within a minute.
- Go back to the webpage where you test your conversion tag when you’re done verifying.
- Click Finish.
Wait at least 24 hours after you have verified your implementation with Google Tag Assistant and your Ad campaigns have run successfully before returning to Google Ads Conversion action to see the results.
Common Mistakes to Avoid in Shopify and Google Tag Manager
Here are some common pitfalls to avoid when working with Shopify and Google Tag Manager:
- Duplicating tracking events: Adding multiple Google tags can result in inflated or inaccurate data.
- Misplacing the GTM code: Always make sure the GTM code is placed immediately after the <head> tag.
- Not testing tags: Always use Preview Mode or Tag Assistant before going live.
Conclusion
By following this guide, you’ll have a fully optimized Google Tag Manager on Shopify setup that tracks user interactions, conversions, and campaign performance without ever needing to modify your code constantly. GTM is a game-changer for any Shopify store, giving you the flexibility and insights required to run successful marketing campaigns and monitor your store’s performance.