
Contact us
Digital Marketing
How to Add Google Tag Manager to a Shopify Store
Feb 6, 2025


Tracking and optimizing your store's performance is essential for driving growth and improving user experience is important in the world of e-commerce. One of the most effective tools for managing tracking codes is Google Tag Manager (GTM). Integrating GTM with your Shopify store allows you to easily add and manage various tracking pixels and codes without the need for constant code edits. In this guide, we'll walk you through the process of adding Google Tag Manager to your Shopify store, exploring its benefits, best practices, and providing step-by-step instructions to ensure a smooth setup.
What is Google Tag Manager?
Google Tag Manager is a free tool from Google that simplifies the management of tracking codes on your website. Instead of manually inserting or updating tracking codes within your site’s code, GTM lets you manage all your tags from one centralized platform. This makes it easier to deploy and update various types of tracking codes, such as Google Analytics, Facebook Pixel, and more, without needing to alter your site's code directly.
Benefits of Using Google Tag Manager
● Centralized Management: Control all your tracking codes from a single interface.
● Ease of Use: Update and manage tags without needing technical expertise.
● Reduced Errors: Minimize the risk of coding mistakes by managing tags through GTM’s user-friendly interface.
● Enhanced Tracking: Implement advanced tracking setups and data collection mechanisms easily.
● Flexibility: Add and modify tags quickly as your tracking needs evolve.
Step-by-Step Guide to Adding Google Tag Manager to Shopify
1. Set Up Your Google Tag Manager Account
Scenario 1: If You Don’t Have a Google Tag Manager Account
Sign Up for Google Tag Manager:
○ Visit Google Tag Manager and log in with your Google account.
○ Click on “Create Account” and enter your account details such as name, country, and website URL.
○ Choose your target platform (Web) and click “Create.”
○ Accept the terms and conditions by checking the box and clicking “Yes.”
Retrieve Your GTM Container Code:
○ After creating your account, you will see your Google Tag Manager code. Keep this page open as you will need the code snippets for the next steps.
○ In your GTM workspace, click on Submit > Publish > Continue to publish your container.
Scenario 2: If You Already Have a Google Tag Manager Account
Log into Google Tag Manager:
○ Go to Google Tag Manager and log in.
Access Your Container Code:
○ Click on Admin in the top header and then select Install Google Tag Manager.
○ Copy both snippets of code provided, as you will need them for the next step.
2. Add Google Tag Manager Code to Your Shopify Store
Note: This method integrates Google Tag Manager across your entire website. Shopify documentation typically restricts GTM to non-checkout pages unless you are a Shopify Plus customer. If you are a Shopify Plus customer, follow the official documentation for Shopify Plus.
Log into Your Shopify Store:
○ Go to Shopify and log in to your store's admin panel.
Access the Theme Code:
○ From the sidebar, under Online Store, click on Themes.
○ Click the kebab menu (three dots) next to your current theme and select Edit Code.
Edit the theme.liquid File:
○ In the search bar, type theme.liquid and click on the file to open it.
Insert the GTM Code:
○ Locate the section of the code that starts with <head>. This is usually near the beginning of the file.
○ Paste the first GTM code snippet immediately after the opening <head> tag.
Example:
html
Copy code
<head>
<!-- Google Tag Manager -->
<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=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXX');</script>
<!-- End Google Tag Manager -->
○ Scroll down to locate the <body> tag or find line 246 under <head>.
○ Paste the second GTM code snippet immediately after the opening <body> tag.
Save Your Changes:
○ Click Save in the top right corner of the editor.
3. Verify Your Google Tag Manager Installation
Open Your Website in Chrome:
○ Navigate to your Shopify store's homepage in Google Chrome.
Use Google Tag Assistant:
○ Click on the Google Tag Assistant Chrome Extension icon in your browser.
○ Click on “Enable” to activate the extension.
Refresh the Page:
○ Reload your Shopify store page and click on the Google Tag Assistant icon again.
Check for Successful Installation:
○ A green tag should appear for Google Tag Manager, indicating that the installation was successful.
Best Practices for Using Google Tag Manager with Shopify
Organize Your Tags and Triggers
● Use Clear Naming Conventions: Ensure that your tags, triggers, and variables are named clearly and consistently. This makes it easier to manage and troubleshoot your GTM setup.
● Create Folders: Organize tags into folders based on their function (e.g., Analytics, Marketing) for better management.
● Regularly Review and Update: Periodically audit your GTM setup to ensure tags are firing correctly and remove any outdated tags.
Implement Common Tags
● Google Analytics: Track pageviews, user behavior, and conversion events by integrating Google Analytics via GTM.
● Facebook Pixel: Add and manage Facebook Pixel to track conversions, retarget website visitors, and optimize ad campaigns.
● AdWords Conversion Tracking: Measure the success of your Google Ads campaigns by implementing AdWords conversion tracking tags.
Monitor and Maintain Your Tags
● Preview and Debug: Use GTM’s preview mode to test your tags before deploying them live.
● Version Control: Utilize GTM’s version control feature to keep track of changes and roll back if needed.
● Regular Testing: Continuously test your tags to ensure they are functioning as expected and capturing accurate data.
Importance of Google Tag Manager for Shopify Stores
Integrating Google Tag Manager with your Shopify store provides several key benefits:
Simplified Tag Management: Manage all your tracking codes from one platform without altering your Shopify theme files directly.
Enhanced Tracking Capabilities: Implement and manage advanced tracking setups for more comprehensive data collection and analysis.
Efficient Updates: Make updates to your tracking codes quickly and efficiently without needing to access your site's code.
Scalability: Easily add new tags and adjust your tracking setup as your store grows and your needs evolve.
Examples of Tags to Add to Your Shopify Store Using GTM
● Enhanced E-commerce Tracking: Track detailed product interactions, including product views, add-to-carts, and purchases.
● Event Tracking: Monitor specific actions such as button clicks, form submissions, and video plays.
● Custom Dimensions and Metrics: Capture additional data points to gain deeper insights into user behavior and site performance.
Conclusion
Adding Google Tag Manager to your Shopify store is a powerful way to streamline your tracking and analytics processes. By following the steps outlined in this guide, you can integrate GTM seamlessly into your Shopify store, enabling more effective data collection and management.
With Google Tag Manager in place, you'll be able to optimize your tracking setup, gain valuable insights into user behavior, and make data-driven
Tracking and optimizing your store's performance is essential for driving growth and improving user experience is important in the world of e-commerce. One of the most effective tools for managing tracking codes is Google Tag Manager (GTM). Integrating GTM with your Shopify store allows you to easily add and manage various tracking pixels and codes without the need for constant code edits. In this guide, we'll walk you through the process of adding Google Tag Manager to your Shopify store, exploring its benefits, best practices, and providing step-by-step instructions to ensure a smooth setup.
What is Google Tag Manager?
Google Tag Manager is a free tool from Google that simplifies the management of tracking codes on your website. Instead of manually inserting or updating tracking codes within your site’s code, GTM lets you manage all your tags from one centralized platform. This makes it easier to deploy and update various types of tracking codes, such as Google Analytics, Facebook Pixel, and more, without needing to alter your site's code directly.
Benefits of Using Google Tag Manager
● Centralized Management: Control all your tracking codes from a single interface.
● Ease of Use: Update and manage tags without needing technical expertise.
● Reduced Errors: Minimize the risk of coding mistakes by managing tags through GTM’s user-friendly interface.
● Enhanced Tracking: Implement advanced tracking setups and data collection mechanisms easily.
● Flexibility: Add and modify tags quickly as your tracking needs evolve.
Step-by-Step Guide to Adding Google Tag Manager to Shopify
1. Set Up Your Google Tag Manager Account
Scenario 1: If You Don’t Have a Google Tag Manager Account
Sign Up for Google Tag Manager:
○ Visit Google Tag Manager and log in with your Google account.
○ Click on “Create Account” and enter your account details such as name, country, and website URL.
○ Choose your target platform (Web) and click “Create.”
○ Accept the terms and conditions by checking the box and clicking “Yes.”
Retrieve Your GTM Container Code:
○ After creating your account, you will see your Google Tag Manager code. Keep this page open as you will need the code snippets for the next steps.
○ In your GTM workspace, click on Submit > Publish > Continue to publish your container.
Scenario 2: If You Already Have a Google Tag Manager Account
Log into Google Tag Manager:
○ Go to Google Tag Manager and log in.
Access Your Container Code:
○ Click on Admin in the top header and then select Install Google Tag Manager.
○ Copy both snippets of code provided, as you will need them for the next step.
2. Add Google Tag Manager Code to Your Shopify Store
Note: This method integrates Google Tag Manager across your entire website. Shopify documentation typically restricts GTM to non-checkout pages unless you are a Shopify Plus customer. If you are a Shopify Plus customer, follow the official documentation for Shopify Plus.
Log into Your Shopify Store:
○ Go to Shopify and log in to your store's admin panel.
Access the Theme Code:
○ From the sidebar, under Online Store, click on Themes.
○ Click the kebab menu (three dots) next to your current theme and select Edit Code.
Edit the theme.liquid File:
○ In the search bar, type theme.liquid and click on the file to open it.
Insert the GTM Code:
○ Locate the section of the code that starts with <head>. This is usually near the beginning of the file.
○ Paste the first GTM code snippet immediately after the opening <head> tag.
Example:
html
Copy code
<head>
<!-- Google Tag Manager -->
<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=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXX');</script>
<!-- End Google Tag Manager -->
○ Scroll down to locate the <body> tag or find line 246 under <head>.
○ Paste the second GTM code snippet immediately after the opening <body> tag.
Save Your Changes:
○ Click Save in the top right corner of the editor.
3. Verify Your Google Tag Manager Installation
Open Your Website in Chrome:
○ Navigate to your Shopify store's homepage in Google Chrome.
Use Google Tag Assistant:
○ Click on the Google Tag Assistant Chrome Extension icon in your browser.
○ Click on “Enable” to activate the extension.
Refresh the Page:
○ Reload your Shopify store page and click on the Google Tag Assistant icon again.
Check for Successful Installation:
○ A green tag should appear for Google Tag Manager, indicating that the installation was successful.
Best Practices for Using Google Tag Manager with Shopify
Organize Your Tags and Triggers
● Use Clear Naming Conventions: Ensure that your tags, triggers, and variables are named clearly and consistently. This makes it easier to manage and troubleshoot your GTM setup.
● Create Folders: Organize tags into folders based on their function (e.g., Analytics, Marketing) for better management.
● Regularly Review and Update: Periodically audit your GTM setup to ensure tags are firing correctly and remove any outdated tags.
Implement Common Tags
● Google Analytics: Track pageviews, user behavior, and conversion events by integrating Google Analytics via GTM.
● Facebook Pixel: Add and manage Facebook Pixel to track conversions, retarget website visitors, and optimize ad campaigns.
● AdWords Conversion Tracking: Measure the success of your Google Ads campaigns by implementing AdWords conversion tracking tags.
Monitor and Maintain Your Tags
● Preview and Debug: Use GTM’s preview mode to test your tags before deploying them live.
● Version Control: Utilize GTM’s version control feature to keep track of changes and roll back if needed.
● Regular Testing: Continuously test your tags to ensure they are functioning as expected and capturing accurate data.
Importance of Google Tag Manager for Shopify Stores
Integrating Google Tag Manager with your Shopify store provides several key benefits:
Simplified Tag Management: Manage all your tracking codes from one platform without altering your Shopify theme files directly.
Enhanced Tracking Capabilities: Implement and manage advanced tracking setups for more comprehensive data collection and analysis.
Efficient Updates: Make updates to your tracking codes quickly and efficiently without needing to access your site's code.
Scalability: Easily add new tags and adjust your tracking setup as your store grows and your needs evolve.
Examples of Tags to Add to Your Shopify Store Using GTM
● Enhanced E-commerce Tracking: Track detailed product interactions, including product views, add-to-carts, and purchases.
● Event Tracking: Monitor specific actions such as button clicks, form submissions, and video plays.
● Custom Dimensions and Metrics: Capture additional data points to gain deeper insights into user behavior and site performance.
Conclusion
Adding Google Tag Manager to your Shopify store is a powerful way to streamline your tracking and analytics processes. By following the steps outlined in this guide, you can integrate GTM seamlessly into your Shopify store, enabling more effective data collection and management.
With Google Tag Manager in place, you'll be able to optimize your tracking setup, gain valuable insights into user behavior, and make data-driven
Tracking and optimizing your store's performance is essential for driving growth and improving user experience is important in the world of e-commerce. One of the most effective tools for managing tracking codes is Google Tag Manager (GTM). Integrating GTM with your Shopify store allows you to easily add and manage various tracking pixels and codes without the need for constant code edits. In this guide, we'll walk you through the process of adding Google Tag Manager to your Shopify store, exploring its benefits, best practices, and providing step-by-step instructions to ensure a smooth setup.
What is Google Tag Manager?
Google Tag Manager is a free tool from Google that simplifies the management of tracking codes on your website. Instead of manually inserting or updating tracking codes within your site’s code, GTM lets you manage all your tags from one centralized platform. This makes it easier to deploy and update various types of tracking codes, such as Google Analytics, Facebook Pixel, and more, without needing to alter your site's code directly.
Benefits of Using Google Tag Manager
● Centralized Management: Control all your tracking codes from a single interface.
● Ease of Use: Update and manage tags without needing technical expertise.
● Reduced Errors: Minimize the risk of coding mistakes by managing tags through GTM’s user-friendly interface.
● Enhanced Tracking: Implement advanced tracking setups and data collection mechanisms easily.
● Flexibility: Add and modify tags quickly as your tracking needs evolve.
Step-by-Step Guide to Adding Google Tag Manager to Shopify
1. Set Up Your Google Tag Manager Account
Scenario 1: If You Don’t Have a Google Tag Manager Account
Sign Up for Google Tag Manager:
○ Visit Google Tag Manager and log in with your Google account.
○ Click on “Create Account” and enter your account details such as name, country, and website URL.
○ Choose your target platform (Web) and click “Create.”
○ Accept the terms and conditions by checking the box and clicking “Yes.”
Retrieve Your GTM Container Code:
○ After creating your account, you will see your Google Tag Manager code. Keep this page open as you will need the code snippets for the next steps.
○ In your GTM workspace, click on Submit > Publish > Continue to publish your container.
Scenario 2: If You Already Have a Google Tag Manager Account
Log into Google Tag Manager:
○ Go to Google Tag Manager and log in.
Access Your Container Code:
○ Click on Admin in the top header and then select Install Google Tag Manager.
○ Copy both snippets of code provided, as you will need them for the next step.
2. Add Google Tag Manager Code to Your Shopify Store
Note: This method integrates Google Tag Manager across your entire website. Shopify documentation typically restricts GTM to non-checkout pages unless you are a Shopify Plus customer. If you are a Shopify Plus customer, follow the official documentation for Shopify Plus.
Log into Your Shopify Store:
○ Go to Shopify and log in to your store's admin panel.
Access the Theme Code:
○ From the sidebar, under Online Store, click on Themes.
○ Click the kebab menu (three dots) next to your current theme and select Edit Code.
Edit the theme.liquid File:
○ In the search bar, type theme.liquid and click on the file to open it.
Insert the GTM Code:
○ Locate the section of the code that starts with <head>. This is usually near the beginning of the file.
○ Paste the first GTM code snippet immediately after the opening <head> tag.
Example:
html
Copy code
<head>
<!-- Google Tag Manager -->
<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=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXX');</script>
<!-- End Google Tag Manager -->
○ Scroll down to locate the <body> tag or find line 246 under <head>.
○ Paste the second GTM code snippet immediately after the opening <body> tag.
Save Your Changes:
○ Click Save in the top right corner of the editor.
3. Verify Your Google Tag Manager Installation
Open Your Website in Chrome:
○ Navigate to your Shopify store's homepage in Google Chrome.
Use Google Tag Assistant:
○ Click on the Google Tag Assistant Chrome Extension icon in your browser.
○ Click on “Enable” to activate the extension.
Refresh the Page:
○ Reload your Shopify store page and click on the Google Tag Assistant icon again.
Check for Successful Installation:
○ A green tag should appear for Google Tag Manager, indicating that the installation was successful.
Best Practices for Using Google Tag Manager with Shopify
Organize Your Tags and Triggers
● Use Clear Naming Conventions: Ensure that your tags, triggers, and variables are named clearly and consistently. This makes it easier to manage and troubleshoot your GTM setup.
● Create Folders: Organize tags into folders based on their function (e.g., Analytics, Marketing) for better management.
● Regularly Review and Update: Periodically audit your GTM setup to ensure tags are firing correctly and remove any outdated tags.
Implement Common Tags
● Google Analytics: Track pageviews, user behavior, and conversion events by integrating Google Analytics via GTM.
● Facebook Pixel: Add and manage Facebook Pixel to track conversions, retarget website visitors, and optimize ad campaigns.
● AdWords Conversion Tracking: Measure the success of your Google Ads campaigns by implementing AdWords conversion tracking tags.
Monitor and Maintain Your Tags
● Preview and Debug: Use GTM’s preview mode to test your tags before deploying them live.
● Version Control: Utilize GTM’s version control feature to keep track of changes and roll back if needed.
● Regular Testing: Continuously test your tags to ensure they are functioning as expected and capturing accurate data.
Importance of Google Tag Manager for Shopify Stores
Integrating Google Tag Manager with your Shopify store provides several key benefits:
Simplified Tag Management: Manage all your tracking codes from one platform without altering your Shopify theme files directly.
Enhanced Tracking Capabilities: Implement and manage advanced tracking setups for more comprehensive data collection and analysis.
Efficient Updates: Make updates to your tracking codes quickly and efficiently without needing to access your site's code.
Scalability: Easily add new tags and adjust your tracking setup as your store grows and your needs evolve.
Examples of Tags to Add to Your Shopify Store Using GTM
● Enhanced E-commerce Tracking: Track detailed product interactions, including product views, add-to-carts, and purchases.
● Event Tracking: Monitor specific actions such as button clicks, form submissions, and video plays.
● Custom Dimensions and Metrics: Capture additional data points to gain deeper insights into user behavior and site performance.
Conclusion
Adding Google Tag Manager to your Shopify store is a powerful way to streamline your tracking and analytics processes. By following the steps outlined in this guide, you can integrate GTM seamlessly into your Shopify store, enabling more effective data collection and management.
With Google Tag Manager in place, you'll be able to optimize your tracking setup, gain valuable insights into user behavior, and make data-driven