Configuring eCommerce tracking with Google Tag Manager (GTM) allows you to track and analyze purchases, transactions, and product data on your website. This setup involves integrating Google Analytics (GA) and GTM to capture valuable eCommerce data, such as transaction IDs, revenue, product details, and more. There are two main types of eCommerce tracking: standard eCommerce tracking and enhanced eCommerce tracking. This guide will cover how to configure both.
Prerequisites
Before starting, ensure that you have:
- A Google Analytics account and a GTM account set up.
- Google Analytics tracking code already installed on your website.
- Developer support for adding the eCommerce data layer to your website.
Step-by-Step Guide to Configure eCommerce Tracking
Step 1: Enable eCommerce Tracking in Google Analytics
- Log in to Google Analytics:
- Go to your Google Analytics account and select the property you want to track.
- Enable Standard eCommerce:
- Go to Admin (bottom-left corner of the GA interface).
- In the View column, select Ecommerce Settings.
- Toggle Enable Ecommerce to ON.
- Click Next Step and then click Submit.
- (Optional) Enable Enhanced eCommerce:
- If you’re setting up enhanced eCommerce, toggle Enable Enhanced Ecommerce Reporting to ON.
- You can also customize your funnel steps here (e.g., checkout steps).
- Click Submit once you’ve completed the setup.
Step 2: Implement the eCommerce Data Layer on Your Website
To track eCommerce interactions (like purchases), you need to pass transaction and product data into the data layer on your website. This requires developer support to ensure the proper data layer structure is implemented.
Here’s an example of how to structure the data layer for a purchase event:
Standard eCommerce Data Layer Example:
Enhanced eCommerce Data Layer Example:
Make sure your data layer contains all relevant eCommerce information (e.g., transaction details, product info). The data layer should be dynamically populated when specific events occur, such as when a customer completes a purchase.
Step 3: Set Up a Transaction Trigger in Google Tag Manager
To track eCommerce transactions, you’ll need to create a trigger in GTM that listens for the eCommerce event in your data layer (e.g., “purchase” or “transaction”).
- Log in to Google Tag Manager:
- Open your GTM workspace.
- Create a New Trigger:
- Go to the Triggers section and click New.
- Name the trigger something descriptive, like “Purchase Event Trigger.”
- Configure the Trigger:
- Set the Trigger Type to Custom Event.
- In the Event Name field, enter the name of the event from your data layer (e.g.,
transaction
orpurchase
). - Select This trigger fires on All Custom Events to ensure it fires on every occurrence of the event.
- Save the Trigger.
Step 4: Set Up an eCommerce Tag in Google Tag Manager
You need to create a Google Analytics eCommerce tag to send the transaction data from the data layer to Google Analytics.
- Go to Tags:
- In GTM, navigate to the Tags section and click New.
- Configure the Tag:
- Name the tag something like “GA eCommerce Tracking Tag.”
- Click Tag Configuration and select Google Analytics: Universal Analytics (for GA4, choose the corresponding tag type).
- Set the Track Type to Transaction (for standard eCommerce) or Event (for enhanced eCommerce).
For Standard eCommerce:
- Under Track Type, choose Transaction.
- Select the Google Analytics Settings Variable for your GA account.
For Enhanced eCommerce:
- Under Track Type, choose Event.
- Set the Event Category to
ecommerce
, Action topurchase
, and leave the label and value fields empty. - Check the box for Enable Enhanced Ecommerce Features and select Use Data Layer.
- If you want to track checkout steps, enable Checkout Tracking and specify the step numbers (e.g., Step 1: Shipping, Step 2: Payment).
- Assign the Purchase Trigger:
- Under Triggering, select the purchase trigger you created earlier.
- Save the Tag.
Step 5: Preview and Test Your eCommerce Setup
- Enable Preview Mode:
- Before publishing your container, click Preview in GTM to enable debug mode.
- Test the Data Layer:
- Visit your website and complete a purchase (or use your staging site for testing).
- In the GTM Debug Console, navigate to the Data Layer tab and ensure that the data layer is being populated with the correct transaction data when a purchase occurs.
- Test Tag Firing:
- Check that the GA eCommerce tag is firing correctly on the purchase event. In the Tags tab of the Debug Console, verify that the tag fires when the purchase event occurs.
- Check Google Analytics:
- Log in to your Google Analytics account and go to Conversions > Ecommerce to verify that the transactions are being tracked. It may take a few minutes for the data to appear.
Step 6: Publish the Container
Once you’ve confirmed that the eCommerce tracking works as expected:
- Exit preview mode.
- Click Submit to publish your container.
Enhanced eCommerce Features
Enhanced eCommerce offers more detailed tracking and reporting compared to standard eCommerce tracking. It provides insights into the full shopping journey, including:
- Product impressions.
- Add-to-cart actions.
- Product detail views.
- Checkout steps.
- Refunds and other user interactions.
To fully leverage enhanced eCommerce, you’ll need to work closely with your development team to implement the appropriate data layer events for each stage of the user journey (e.g., product detail views, adding items to the cart, and completing a purchase).
Example of Enhanced eCommerce Events:
- Product Detail Views:
- Add to Cart:
Each of these events will need a corresponding GTM tag to ensure the data is sent to Google Analytics properly.
Conclusion
Configuring eCommerce tracking with Google Tag Manager and Google Analytics involves implementing a data layer, setting up appropriate triggers and tags, and testing the setup to ensure accurate data collection. By leveraging enhanced eCommerce tracking, you can capture valuable insights into your customers’ purchase behaviors and optimize your sales funnel accordingly. Once set up correctly, eCommerce tracking provides a wealth of data to help drive business decisions and increase conversions.