Google Analytics 4 / GA4 – Enhanced Ecommerce tracking – How to setup?
WARNING!
This guide doesn’t consider whether you’re utilizing a Consent Management Platform (CMP) or your preferred method for incorporating Google Consent Mode into your Google Tag Manager container. The steps to ensure the privacy of your measurement setup often rely on your chosen CMP. Reach out to your CMP’s support team for assistance.
What is this article about?
This article will show you how to setup ecommerce tracking for your Google Analytics 4 property with Google Tag Manager, WooCommerce and GTM4WP. GTM4WP uses the recommended event names of Google to send ecommerce actions like add to cart, product click or purchase.
This page describes GTM4WP 2.0.0 and newer. Where the legacy 1.x versions of the plugin behaved differently, the older behavior is marked with a bold GTM4WP 1.x: lead-in.
You do not need to setup anything in your Google Analytics 4 property to be able to analyze ecommerce data. It will automatically pick up ecommerce events and data and show the results in the Ecommerce purchases report.
Step 0: pre-setup checks
Two things need to be in place before you import anything into your container.
Turn on ecommerce tracking in the plugin
- Open the GTM4WP plugin settings page and go to the WooCommerce section
- In the General group, turn on Track e-commerce
- Save the plugin settings
This option is off by default. While it is off, GTM4WP does not register any of its ecommerce hooks, so no ecommerce data reaches the data layer and the tags described below have nothing to fire on.
GTM4WP 1.x: the same option lives on the Integration->WooCommerce tab.
Add the Google tag
In your Google Tag Manager container, you will first need to add a generic Google tag if you haven’t added it yet. This will store your Google Analytics 4 web stream ID (G-XXXXXXXXX) and every global attribute you set in it. It will also send the page_view event if you do not change the default options in the tag.

- Start adding a new tag
- Select Google tag
- Enter your Google Analytics 4 measurement ID (also known as web stream ID)
- It is recommended to store this ID into a variable of the type constant, as it will be needed in your event tracking tags as well. The container template imported in Step 1 already contains such a constant
- Depending on your setup in GA4 admin, you might want to enter the more generic Google Tag ID (GT-XXXX) which will also work, but in GA4 event tags, you will always need to enter the GA4 measurement ID
- If you are unsure what other options need to be set in this tag, leave everything else in its default state
- Enter a name at the top of the panel (in the example below you see: Google Tag – Pageview – All pages
- Attach a trigger to the tag: you may chose the generic All pages trigger automatically created in every GTM container but you can also select the Initialization – All pages trigger to make sure the page view event is sent before all other events. Note: it is not guaranteed that this way all page view events will be the first during a page load but it will have a higher chance.
- Save the new tag
Step 1: import GTM4WP Google Analytics 4 container template
- Download the following Google Tag Manager GA4 container template (last updated: 2026. 08. 10)
- On the Google Tag Manager UI, open Admin / Container / Import Container:

- Select the previously downloaded file
- We highly recommend to create a new workspace during the import process (enter a workspace name you wish)
- Select the Merge import option
- To stay on the safe side, select Rename conflicting tags, triggers, and variables
- You should see only “New” items in the summary table. If you see modified or deleted items as well, check the details in consult with a Google Tag Manager expert if needed
- Click the Confirm button to proceed
If you imported an earlier version of this template before August 2026, import the current file as well. The entity names have not changed, so the merge updates what already exists instead of creating duplicates.
The triggers created by the import
- Event – Ecommerce Events: it will fire on all ecommerce events in your WooCommerce shop
- Event – Purchase: it will fire on the purchase event only. The two Google Ads tags use this trigger
The tags created by the import
- GA4 – Event – Ecommerce events: fires on the ecommerce events trigger and sends the name of the last ecommerce action using the recommended retail event names of Google. This is the tag this article sets up
- Google Ads – Conversion – Purchase: covered by the Google Ads conversion tracking guide
- Google Ads – User-provided Data – Purchase: covered by the Enhanced Conversions guide
The two Google Ads tags ship with placeholder IDs. If you are not setting up Google Ads now, pause them until you do, so they do not fire with placeholder values.
The variables created by the import
The template contains 68 variables. Only the ecommerce group and the GA4 ID constant are needed for the setup described here. The rest are there so that other tags can be fed with the same data without building anything by hand.
- Ecommerce: helper variable to pull the most recent ecommerce data from the data layer
- Ecommerce Items: returns the most recent product data in the data layer. You can use this variable in a Google Ads remarketing tag to populate dynamic remarketing data
- Ecommerce Transaction ID: the order ID on the order received page. You can use this variable in other tags where you need to transmit the ID of the order just placed on your site
- Ecommerce Value: the total value of the order on the order received page. You can use this variable in other tags where you need to transmit the value of the order just placed on your site
- Ecommerce Tax: the total tax value of the order on the order received page
- Ecommerce Affiliation: usually empty, could include any affiliate partner name in the future
- Ecommerce Shipping: the total shipping cost of the order on the order received page
- Ecommerce Coupon: it includes all coupon codes in a comma separated list that has been redeemed during checkout (variable populated only on the order received page)
- Ecommerce Currency: the currency used in the last ecommerce action. You can use this variable in other tags where you need to transmit the currency of the order just placed on your site
The remaining variables fall into these groups:
- 25 variables prefixed with Order Data –, which read the order on the order received page. They stay empty unless the Order data in data layer option is on in the Data layer content group of the plugin’s WooCommerce section
- 25 variables prefixed with Customer –, which read the account details of a logged-in customer on every page. They need the Customer data in data layer option in the same group
- User Data (Enhanced Conversions) and User-Provided Data, which carry the identifiers used by Enhanced Conversions. These also need the Customer data in data layer option
- Customer Type and New Customer, which tell new and returning buyers apart on the purchase event
- 5 constants: GA4 ID, Google Ads Conversion ID, Google Merchant Center ID, Google Merchant Center Feed Country and Google Merchant Center Feed Language. Only the first one matters for this guide
The import also activates the built in Event variable.
Step 2: enter your GA4 measurement ID
The ecommerce tag does not hold your measurement ID directly. It reads the GA4 ID constant, which the template ships with the placeholder G-XXXXXXXXXX.

- Open the Variables section and edit the GA4 ID constant
- Replace the placeholder with your own GA4 measurement ID
- Do NOT enter your Google Tag ID here even if you did this in your Google Tag
- Save the variable
- Open the “GA4 – Event – Ecommerce events” tag and make sure the message next to the measurement ID says Google tag found in this container!
Publish everything.
All done!
At this point you setup everything to track ecommerce for Google Analytics 4 in your WooCommerce store. Enjoy! 🙂

