How to Setup Google Tag Manager on Your Shopify Store

Last Updated on

I've found that oftentimes the best way to solve complex problems is with innovative solutions. If the problems are complex enough, then your solution could really make the difference in your business - since no one else is solving these problems effectively!

How can one create more value for their customers than their competitors? It's by innovating processes and implementing procedures that practically no one else is doing.

Use of Data Can Lead to Competitive Advantages

One of the easiest ways to bolster profitability in the long run for your Shopify store is to setup custom event tracking in Google Analytics. With this event tracking, you're able to customize the data that you're gathering for specific conversion elements throughout your funnel.

IBM's graphic showing how elite companies use data HEAVILY in business.

Fail to have this implemented properly on your Shopify store in some capacity, and you're setting yourself for lots of missed profits and the potential for competitors to squeeze you out of your niche all together!

If your competitor is able to see the flow of traffic and optimize their entire website around how the customer is interacting with the sales funnel better than you can, then they'll eventually be able to spend more to acquire a customer than you, and they'll effectively squeeze you out of effectively advertising to your customers.

Implementing Google Tag Manager on Shopify

After looking at Shopify documentation it would seem that they really only go over how to do this for Shopify Plus stores. Therefore, they really only think their largest customers need to know how to implement this.

However, what we want to do is grow our store to one of the largest stores using Shopify, so it would be prudent to implement what the big players are using now in order to actually get there, make sense?

After doing my own research, I've found that there are two primary ways to implement Google Tag Manager yourself:

  1. Implement directly into your Shopify store's theme.liquid code. The caveat with this is that the checkout and thank you page won't be collecting data.
  2. Implement with Google Analytics admin settings for coverage of all pages on store

If you're a non-Shopify plus store, then it only makes sense to go with the Google Analytics route so that you can get coverage on all pages of your store and really maximize the value of the data that you're receiving.

Implementing With Google Analytics: Step-By-Step

Let's first go over how to implement it using Google Analytics, the choice that I definitely recommend going for. This is a really quick implementation too because you only have to set it up in one place on your store.

First, you'll want to get Google Analytics installed onto your Shopify store. 

Login to Google Analytics and from there go to the Admin page. Within the account pane on this page you can add a new account (this will be your store, make it the name of the account, and direct it to the corresponding URL).

Once the account is made, grab the Google Analytics Universal tracking code (GA script) under Tracking Info -> Tracking Code. By default after creating the new Google Analytics account, you're directed to the GA code.

With the code above copied, go to your Shopify Admin dashboard -> Online Store -> Preferences -> Google Analytics. Paste the code into the Google analytics account pane on this page. 

Click Save. 

Now, many of you will have already done this step, but here's where we have a little bit of customization to do to make sure Google Tag Manager is fully setup on our store. 

We now want to add a custom JavaScript to the Google Analytics pane on our Shopify dashboard (located where we added the first bit of code).

The code we need will require us to sign up for Google tag manager specifically. Go to this website and sign up for free (I would recommend making your account the same name as your Google Analytics one, for ease of use).

Once inside, copy the code from the main Overview dashboard.

And paste it into the Shopify Custom Javascript section.

That's it! You've successfully implemented Google Tag Manager on your store. 

Now, let's do some testing to make sure everything is working properly.

Testing to Ensure Google Tag Manager is Working

Regardless of the benefits of having Google Tag manager implemented on your Shopify store, you'll definitely want to keep the enhanced ecommerce and analytics options open on the store itself.

It's just not worth the time it would take to do this in GTM, and you'd be better off spending that time working on your products or marketing them!

To test everything out, let's create a new Universal Analytics tag inside tag manager. Choose an event track type that'll execute on all pages.

On GTM, browse to:

 Tags -> Create a new container -> Google Analytics - Universal Analytics option from right sidebar -> Tag Configuration -> Track Type = Event -> Trigger = All Pages.

We'll also need to set a new variable type under the event tracking pane.

Under 'tracking ID' choose {{Page_Hostname}} and Save with a desired name.

With those settings in place, we can save our new container and give it a name. In this example I'm just keeping the default names for containers generated by GTM.

With that in place we can now enter preview mode in the top right corner of this screen.

You can now browse to your website's URL and see the test tags that should be triggering as you navigate your entire website (using the Universal tracking code in this instance). These should also be triggering when you do your test order too!

What's great is that this code should be firing on all of your pages and can provide extremely useful data heading forward.

Obviously the checkout funnel will be where you want to emphasize the analytics, but even having data on customers viewing your about us pages, legal pages, contact us pages, blog pages, etc. is super useful data to have depending on your vision for your website and where the traffic is coming from. 

Implementing With theme.liquid

Like I said previously, I don't recommend you use this method of implementation, but it can certainly be done.

Copy the code from GTM that we'll be placing in the header section.

Place this code in your theme.liquid in the appropriate section.

(From Shopify dashboard navigate to Online Store -> Themes -> Left-click on the Actions Dropdown menu -> Click 'Edit Code' -> Click Theme.Liquid)

Hit Save.

Additionally, we'll need to grab the 'noscript' code and place it at the top of body in our theme.liquid

Paste this code into the theme.liquid appropriate section shown below:

Hit Save again and you're done!

If you're on Shopify Plus (not likely), then you'll want to implement this on checkout.liquid too for maximum coverage.

Wrapping Up and An Alternative Solution

You can also install GTM using an app by Elevar called dataLayer. It's a pretty neat app and allows you to do some unique things with Adwords too. Check it out now

That about wraps up this article on the subject though. I may go more in-depth on this in the future, but this will fully get you setup with GTM on your store. The data that you receive from these tags can be game-changing if you're serious about your business.