Set up Google Tag Manager with Google Analytics for Magento

Published
/
Updated
September 12, 2018
/
From

Magento just introduced native Google Tag Manager support in release 1.14.2. Unfortunately, setting up Google Tag Manager is complicated. Complicated enough that you might reconsider switching it on in the first place.

To make matters worse, Magento’s guide to implementing Google Tag Manager skimps on the details. At the time of writing, it doesn’t cover required GTM setup to send Google Analytics’ Enhanced Ecommerce data through Google Tag Manager—a crucial insight tool for any eCommerce site.

Modifying something as business-critical as analytics isn’t something undertake lightly. You need confidence that you’re going capture data at the same fidelity you have in the past. Luckily, I’ve already done the legwork for you and verified it captures data accurately, so read on and you’ll be set!

This integration only exists in Magento Enterprise, 1.14.2 and above. If you don’t have Magento Enterprise 1.14.2 or higher, you’ll need a developer to implement Google Tag Manager support.

(We’ve worked on a lot of analytics integrations, so if you need help, get in touch!)

Table of Contents

Here’s an overview of the steps we’ll be taking to set up Google Tag Manger for Magento.

  1. Benefits of using Google Tag Manager for Magento
  2. How to set up Google Tag Manager in Magento
  3. Create a tag to track page views in Google Analytics
  4. Set up triggers for the events Magento sends Google Tag Manager
  5. Create a new tag to send trigger data to Google Analytics
  6. Publish your Google Tag Manager updates
  7. Ensure Google Analytics is set up for Enhanced eCommerce
  8. Update your Magento configuration to use Google Tag Manager
  9. Google Tag Manager is live!

Chat with a Magento Certified Developer now

Time to get the ball rolling on a project? Shoot us an email and you’ll be talking to a Magento Certified Developer ASAP.

Benefits of using Google Tag Manager for Magento

There are a bunch of benefits to using Magento’s new integration with Google Tag Manager. If you already know why it’s awesome, skip to the installation instructions below.

Google Tag Manager is the only analytics option in Magento that supports Enhanced Ecommerce tracking out of the box. The integration is brand new and deeply integrated into the platform. It will give you much more insight into how users flow through your site.

For example, Enhanced Ecommerce will surface checkout churn rates.

Enhanced Ecommerce also surfaces high level customer journey information. This kind of information is an excellent place to kick off investigation into areas that could benefit most from optimization.

Google Tag Manager tracks your overall revenue more accurately too. In addition to capturing purchase information on the order success page, it sees refunds administered through Magento’s admin panel. This reduces discrepancies between your revenue and Google Analytics’ reported revenue. This can help you more accurately determine information like where your most valuable customers come from.

How to set up Google Tag Manager in Magento

Here’s the meat of this post. There’s a lot to do here. Pull up the GTM admin panel in another window and place these instructions side-by-side. It’ll save you some time switching back and forth.

1. Create a tag to track page views in Google Analytics

Tags link events on your site to data consumers like Google Analytics. GTM comes with a few baked-in events it listens for, like page views. We’ll use the page view event to send the proper data to Google Analytics here.

Set up your Google Tag Manager account if you haven’t already—pick an account name and click “Continue.”

2. Create a new container with your store’s URL. Select the “Web” option and click “Create.”

3. Accept the terms and conditions and ignore the embed code—the code you need is already in Magento 1.14.2.

4. Select “Tags” from the left navigation menu and create a new tag. On the new tag page, pick Google Analytics as your product.

5. Pick “Universal Analytics” as your tag type

6. Drop in your Google Analytics Tracking ID. It’s a snippet of text that looks something like this: UA-XXXXXXX-XX. Learn how to find your Google Analytics Tracking ID. You can leave everything else as is.

7. We want this event to fire on “All Pages”, so select that option from the list.

8. Save the tag.

How to set up triggers for the events Magento sends Google Tag Manager

There are various events Magento has introduced in 1.14.2 that send relevant data to the Google Tag Manager data layer. We need to tell GTM what these events are so it knows to listen to them.

1. Navigate to the “Triggers” tab on the left of the Google Tag Manager admin screen for your container.

2. Create a new trigger and select “Custom Event” from the event types. 

3. Insert one of the following as the event name in the the “Fire on” section:

  • addToCart
  • checkoutOption
  • checkout
  • productDetail
  • productImpression
  • purchase
  • refund

4. Name the trigger and save it.

5. Repeat steps one through four for the rest of the event names in the list.

How to create a new tag to send trigger data to Google Analytics

The triggers in the last section tell Google Tag Manager what events to look out for, but we still need to tell it where to send that data. We’ll create another tag to accomplish that for us.

1. Click on “Tags” in the left navigation menu and create a new tag.

2. Select Google Analytics and Universal Analytics again.

3. Insert your Google Analytics tracking ID again—the same one as before.

4. Make the following selections—all found under the “Configure Tag” header.

Track Type: Event

Non-Interaction Hit: True

Enable Enhanced Ecommerce Features: True

Use data layer: True

5. In the “Fire On” section, select “More”, then check the boxes next to all the custom events we created in the last section.

6. Save the tag.

How to publish your Google Tag Manager updates

Google Tag Manager has a version control system in place so containers you’re working aren’t automatically published to your live site before they’re ready. Ours is finally ready, so we need to publish our most recent changes.

1. Click the “Publish” button in the upper right of the GTM control panel

2. Click “Publish Now” in the modal window that pops up.

3. You’re all done with Google Tag Manager for now! Make a note of your Google Tag Manager container ID—it’ll look something like this: GTM-XXXXXX.

How to ensure Google Analytics is set up for Enhanced Ecommerce

Now we’re done with Google Tag Manager. If you haven’t set up Enhanced Ecommerce in Google Analytics yet, this section will walk you through the required actions to activate it.

1. Visit the Google Analytics dashboard for your site.

2. Click the “Admin” tab at the top of that page.

3. On the far right, in the “View” column, you’ll find a link labeled “Ecommerce Settings”. Click it.

4. Enable Enhanced Ecommerce as well as Related Products. Click the “Next Step” button.

5. Enable Enhanced Ecommerce and add the following checkout funnel steps (in order)

  • ‍Login/Guest Checkout
  • ‍Billing Information
  • ‍Shipping Information
  • ‍Shipping Method
  • ‍Payment Information
  • ‍Order Review

6. Submit the form and you’re done!

How to update your Magento configuration to use Google Tag Manager

The final step—nice work! Now all that’s left is to configure Magento to start using Google Tag Manager.

1. Log in to you Magento admin account.

2. Visit the “Configuration” tab under “System” at the top of the page.

3. Navigate to “Google API” in the list on the left of the Configuration page. You can find it under the “Sales” header. Click on it.

4. Enable the Google API and change the dropdown for “Account Type” to Google Tag Manager. Insert your Google Tag Manager container ID into the “Container Id” field.

5. Save your new configuration and you should be good to go! You may have to clear your cache for changes to take effect.

Google Tag Manager is live!

Congratulations! Your enhanced e-commerce tracking is live. You’ll soon have much more valuable insight into how your customers are using your site. Use this information to drive your optimization campaigns.

As always, I recommend setting up a change to your analytics on a staging site first, with its own analytics account. Use that site to verify the accuracy of your tracking codes before you take it live. Please don’t hesitate to contact us if you have any questions about implementation or investigating the results of your improved analytics tracking. Happy selling!

Related articles

Make Magento faster without touching code
Configuration is key to ensuring your Magento store loads quickly.
Read this article
6 tips to optimize your eCommerce homepage for conversion
Are you taking advantage of one of your strongest eCommerce assets?
Read this article
3 Design Patterns with High Conversion Rates
Identify persuasive design patterns common across product pages boasting high conversion rates.
Read this article

Work With Us

We help marketing teams build eCommerce sites that grow.
Find out how.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.