Tracking & Analytics· SOP 20

How to Install Google Tag Manager on Your Shopify Store

To add Google Tag Manager to a Shopify site.

3 min read31 steps17 screenshots747 words

Prefer a shortcut? 16 free tools do parts of this for you.

Aim: To add Google Tag Manager to a Shopify site.

Optimal Outcome: Google Tag Manager is properly installed without any technical issues.

What do you need to start: Google Tag Manager is available only to stores on the Shopify Plus plan.

Why is this SOP Important: Google Tag Manager is a great tool to help you collect, track, and analyze important data about your Shopify store more easily.

When and Where to execute: Only once—the first time you install Google Tag Manager—in your Shopify admin.

Who Should Be Doing This: The person responsible for website management or analytics.

Environment Setup

Important: This SOP works only for accounts using Shopify Plus plans

  1. Go to Google Tag Manager, click the “Accounts” tab, and click “Create Account”.

  1. Fill in the following information:

    1. Account Name — The name you use to identify this account.

    2. Country — Country origin.

    3. Container name — Insert the URL of your website

    4. Target platform — Where do you plan to add Google Tag Manager (e.g. on your website, mobile, etc)

    5. (Optional) Share data anonymously with Google.

  1. Once finished. Click “Create”.

  2. You’ll see a Google Tag Manager Terms of service pop up. Select the checkbox and click “Yes”.

  1. You will see the code to install Google Tag Manager. Ignore this for now. Click “OK” to close the pop up.

  2. Once you are in your Workspace, make note of your Google Tag Manager ID.

  1. Click on Submit > Publish > Continue to publish your Google Tag Manager container.

Add Google Tag Manager code to your Shopify theme

  1. Log in to your Shopify account.

  2. In your Shopify admin, click “Online store”, and then click “Themes”.

  3. In the theme drop-down, click “Edit Code”.

    1. Note: Before you proceed, you can choose to duplicate your theme first for backup.

  1. Go back to Google Tag Manager and copy the first code snippet into the <head> tags of your theme.liquid and checkout.liquid code:

    1. Click your Google Tag ID Manager.

  1. Copy the code from the first box. You can find it directly under the text “Paste this code as high in the <head> of the page as possible:

  2. In your Shopify admin, open your theme.liquid file. Paste the code snippet as high in the <head> of the theme.liquid code as possible.

  1. Open your checkout.liquid file. Paste the code snippet as high in the <head> of the checkout.liquid code as possible.

  1. Go back to Google Tag Manager and copy the second code snippet into the <body> tags of your theme.liquid and checkout.liquid code:

    1. Click your Google Tag ID Manager.

  1. Copy the code from the second box. You can find it directly under the text “Additionally, paste this code immediately after the opening <body> tag:

  2. In your Shopify admin, open your theme.liquid file. Paste the code snippet as high in the <body> of the theme.liquid code as possible.

  1. Open your checkout.liquid file. Paste the code snippet as high in the <body> of the checkout.liquid code as possible.

  1. In your Shopify admin, click “Save”.

Verify that Google Tag Manager is Installed

  1. Open your Google Tag Manager and click “Preview”.

  1. Input your store’s URL and click “Connect”.

  1. If the Google Tag Manager installation is successful, you will be redirected to your store page and you will see a pop up at the bottom right corner with the prompt “Tag Assistant Connected”.

  1. You will also see a “Connected!” prompt when you go back to Google Tag Manager. Click “Continue” and you’re done.

Conclusion

And that's it!

You have successfully integrated Google Tag Manager with your Shopify store.

Execution Checklist:

  • Set up your Google Tag Manager account.

  • Copy the first code snippet from Google Tag Manager and paste it into the <head> tags of your theme.liquid and checkout.liquid code.

  • Copy the second code snippet from Google Tag Manager and paste it into the <body> tags of your theme.liquid and checkout.liquid code.

  • Don’t forget to click Save.

  • Verify integration by going back to Google Tag Manager, clicking the Preview button, typing your store’s URL, and clicking Connect.

  • Once you see a pop-up that says “Tag Assistant Connected”, you’re all done.