Although the steps bellow will give you proper ecommerce data collection in Google Analytics, there is an easier way now. The article will be updated soon.
This article will show you how to setup ecommerce tracking for your Google Analytics 4 property with Google Tag Manager, WooCommerce and GTM4WP. Google Analytics 4 or GA4 is the next generation of the popular free tool Google Analytics. It uses a completely different data model as well as new reports and user interface. GTM4WP uses the recommended event names of Google to send ecommerce actions like add to cart, product click or purchase.
This article is for users of Google Tag Manager for WordPress plugin v1.12 or newer. If you are using an older version of my plugin, please consider to upgrade.
If you are looking for setup instructions to your Universal Analytics or GA3 tags, please visit the GA3 version of this article.
Step 0: pre-setup checks – Google Analyitcs 4 configuration variable
You do not need to setup anything in your Google Analytics 4 properties. It will automatically pick up ecommerce events and data and show you the results in monetization reports.
In your Google Tag Manager container, you will first need to add a Google Analytics 4 configuration 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 a page_view event if you do not change the default behavior of the tag.
- Start adding a new tag
- Select Google Analytics: GA4 Configuration
- Enter your Google Analytics 4 measurement ID (also known as web stream 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: GA4 – Pageview – All pages
- Save the new tag
Step 1: import GTM4WP Google Analytics 4 container template
- Download the following Google Tag Manager GA4 container template
- 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
This import process will create the following new trigger in the workspace
- Event – Ecommerce Events GA4: it will fire on all ecommerce events in your WooCommerce shop
The following variables will be created:
- 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 following tag will be created:
- GA4 – Event – Ecommerce events: fires using the trigger described above, uses the event name of the last ecommerce action using the recommended retail event names of Google. Includes all the required ecommerce parameters using the variables listed above
Step 2: complete the newly created ecommerce event tag
- In Step 0, you either already had a “Google Analyitcs 4: GA4 configuration tag” or you created it while going through the steps
- Open the “GA4 – Event – Ecommerce events” tag that has been just created in Step 1
- Open the list in the Configuration Tag drop down
- Select your GA4 configuration tag (the name might be different than on the screenshot above)
- Save the changes
At this point you setup everything to track ecommerce for Google Analytics 4 in your WooCommerce store. Enjoy! 🙂