Add Google Tag Manager to Shopify

Contributors

@victoriadynamicdata-agency


Business Benefits

Track complex interactions and engagements without having to rely on out-of-the-box Shopify apps.


Log in to Shopify, navigate to Sales Channels > Online Store > Themes, and click on Actions > Edit code to enter the theme editor.

Go to the Layout folder and open the theme.liquid file to display it in the editor window on the right.

  • Find the opening of the `` section in the file.

Open Google Tag Manager and click on the account ID in the top navigation bar to bring up the installation script.

Click on the copy icon in the first section of code from GTM.

Note that there are two versions of the GTM installation code:

  • The first is JavaScript code that goes in the `` section of the theme file.
  • The second is a no script version designed for browser clients that cannot read JavaScript - it goes in the `` section of the theme file.

In your Shopify window, paste the script at the top of the `` section in the theme.liquid file.

Click on the copy icon in the second - no script - section of code from GTM.

In your Shopify window, paste the no script code just after the opening `` tag in the theme.liquid file.

Click the Save button at the top of the page.

Click on Settings and Checkout to access the Checkout Settings dashboard.

Paste both the JavaScript and the no script versions of the GTM code on the checkout pages.

  1. Scroll down the checkout settings page until you find the Additional scripts box.
  2. Paste the JavaScript version of the code here.
  3. Paste the no script version of the code right below it.
  4. Click the Save button.

Last edited by @hesh_fekry 2023-11-14T15:45:45Z