In this guide, we will walk through the process of setting up e-commerce tracking for Google Analytics 4 (GA4) using Google Tag Manager (GTM).
This setup is crucial for online store owners to analyze sales, properly configure conversions, and boost the success of Google Ads campaigns. Although we will focus on WordPress sites with WooCommerce integration, the principles are applicable to other platforms as well. Let’s dive in! ✌️
I uploaded a step-by-step YouTube video in the Romanian language. English subtitles are available.
Why E-commerce Tracking in GA4 is Essential
Implementing e-commerce tracking in GA4 allows you to:
- Track product views, cart additions, and purchases
- Analyze revenue and sales data
- Optimize marketing strategies and ad spend
- Enhance user experience on your online store
Prerequisites
Before we begin, ensure that your website has data layers built-in. These data layers will enable Google Tag Manager to extract user interaction data and send it to GA4. This data includes product views, cart actions, purchases, and revenue information.
Types of E-commerce Events in GA4: Google’s documentation outlines several types of e-commerce events that can be tracked.
Subscribe to Marketing Newsroom, and you will receive the newsletter every Wednesday.
*Note: the newsletter uses Romanian language.
1. Setting Up Data Layers
First, we need to ensure that our data layers are correctly implemented. If you’re using WooCommerce on WordPress, follow these steps:
- Install and Activate GTM Plugin: Go to your WordPress dashboard, navigate to Plugins > Add New, and search for ‘gtm 4wp’. Install and activate the plugin
- Configure Plugin Settings: In the plugin settings under the General tab, add your Google Tag Manager ID. Turn off unnecessary options and save changes.
- Set Up WooCommerce Integration: In the Integration tab, enable tracking for e-commerce, cart content, customer data, and order data in the data layer.
2. Creating Tags and Triggers in GTM
- Create a New Tag: In GTM, create a new tag and name it ‘Google Analytics 4 E-commerce’. Select the GA4 Event tag type.
- Enter Measurement ID: Input your GA4 data stream ID. You can create a constant for the ID to simplify the process.
- For the Event Name choose the Event, custom event. In More Settings, choose Send Ecommerce Data and leave the Data Layer option enabled. In Advanced Settings, go to Consent Settings and choose No additional consent required, since this is a Google tag with built-in consent. However, make sure you have done the setup according to this Consent Mode v2 article.
- Set Up Triggers: Create a trigger named ‘eCommerce All Events’ and set it to fire on custom events matching the e-commerce events from Google’s documentation. Enable Use regex matching and add these events:
view_item|select_item|add_to_cart|remove_from_cart|view_cart|begin_checkout|
add_payment_info|add_shipping_info|purchase
The tag will fire when any of these events will happen in the user’s journey. Save the trigger and then save the tag.
3. Testing and Publishing
- Simulate a Purchase: Use GTM’s preview mode to simulate a purchase on your site. Add a product to the cart, proceed to checkout, and place an order.
- Check Data Layer and Tag Activation: In Tag Assistant, verify that the tags are firing correctly and that the data layer contains the expected information.
- Publish Changes: Once confirmed, publish your GTM container to make the changes live.
Verifying E-commerce Tracking in GA4
After setting up and publishing, navigate to your GA4 property to verify that e-commerce data is being collected. Check the e-commerce reports to ensure they display accurate and comprehensive data about user actions on your site.
Conclusions
Setting up e-commerce tracking in Google Analytics 4 using Google Tag Manager is a powerful way to gain insights into your online store’s performance. By following this guide, you can ensure that your e-commerce data is accurately tracked and leveraged for better business decisions.
Don’t forget to subscribe to our channel for more tutorials, and stay tuned for more insights on using Google Tag Manager and Google Analytics 4.