Skip to content
Facebook Twitter Github RSS
Google Tag Manager for WordPress
  • Home
  • FeaturesExpand
    • Basic features of GTM4WP

      You can use many post or page attribute in you Google Tag Manager setup even for custom post types and taxonomies.

      Basic data

      Page / post attributes

      Site search

      User data

      Multisite data

      3rd party data

      Browser attributes

      Device attributes

      Operating system attributes

      Weather conditions

  • SetupExpand
    • Setup advanced GTM4WP features

      Integrate your measurement with WooCommerce, setup Google Analytics 4, Google Ads remarketing or conversion tracking maximizing capabilities.

      WooCommerce related

      Google Analytics 4

      Google Ads – Dynamic Remarketing

      Google Ads – Conversion tracking

      Google Ads – Enhanced Conversions

      Other setup articles

      Exclude WordPress admins

      Embedded media players

  • DevelopersExpand
    • Information for developers and WP managers

      There are several tools in GTM4WP to support your special needs and to adjust plugin behavior to your website or WooCommerce shop.

      Do you want to contribute with a bugfix or a new feature? Visit the GTM4WP’s GitHub page!

      For Developers

      Actions and filters

      WP themes + Proper ecommerce tracking

      For WP managers

      Setup GTM Environments

      Hard code GTM parameters

  • Blog
  • GDPR
Download
Google Tag Manager for WordPress
Home / Google Tag Manager for WooCommerce / Google Analytics 4 / GA4 – Enhanced Ecommerce tracking – How to setup?

Google Analytics 4 / GA4 – Enhanced Ecommerce tracking – How to setup?

Google Analyitcs 4 ecommerce tracking

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?
  • Step 0: pre-setup checks – Google Tag
  • Step 1: import GTM4WP Google Analytics 4 container template
    • This import process will create the following new trigger in the workspace
  • Step 2: complete the newly created ecommerce event tag

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 article was created for users of Google Tag Manager for WordPress plugin v1.12 or newer. If you are using an older version of the 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.

You do not need to setup anything in your Google Analytics 4 properties to be able to analyze ecommerce data. It will automatically pick up ecommerce events and data and show the results in monetization reports.

Step 0: pre-setup checks – 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.

Setup your Google Tag for Google Analytics 4 page view tracking.
  • 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
    • 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: 2024. 01. 29)
  • On the Google Tag Manager UI, open Admin / Container / Import Container:
Import Container element in Google Tag Manager admin
  • 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

It will also activate the built in Event variable. These imported variables will not be needed to send ecommerce data for Google Analytics however they will be useful to fuel other tags with the same data.

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

Google Analyitcs 4 ecommerce tracking - finish tag setup
  • Open the “GA4 – Event – Ecommerce events” tag that has been just created in Step 1
  • Either enter your GA4 measurement ID or select a variable that will hold this ID while the container is loaded into your website
    • Do NOT enter your Google Tag ID here even if you did this in your Google Tag
  • Make sure the message next to the measurement ID says Google tag found in this container!
  • Save the changes

Publish everything.

All done!

At this point you setup everything to track ecommerce for Google Analytics 4 in your WooCommerce store. Enjoy! 🙂

© 2025 Google Tag Manager for WordPress - Privacy policy

  • WordPress.org plugin page
  • Plugin support
  • Plugin reviews
  • Home
  • Features
    • Basic features of GTM4WP

      You can use many post or page attribute in you Google Tag Manager setup even for custom post types and taxonomies.

      Basic data

      Page / post attributes

      Site search

      User data

      Multisite data

      3rd party data

      Browser attributes

      Device attributes

      Operating system attributes

      Weather conditions

  • Setup
    • Setup advanced GTM4WP features

      Integrate your measurement with WooCommerce, setup Google Analytics 4, Google Ads remarketing or conversion tracking maximizing capabilities.

      WooCommerce related

      Google Analytics 4

      Google Ads – Dynamic Remarketing

      Google Ads – Conversion tracking

      Google Ads – Enhanced Conversions

      Other setup articles

      Exclude WordPress admins

      Embedded media players

  • Developers
    • Information for developers and WP managers

      There are several tools in GTM4WP to support your special needs and to adjust plugin behavior to your website or WooCommerce shop.

      Do you want to contribute with a bugfix or a new feature? Visit the GTM4WP’s GitHub page!

      For Developers

      Actions and filters

      WP themes + Proper ecommerce tracking

      For WP managers

      Setup GTM Environments

      Hard code GTM parameters

  • Blog
  • GDPR
Search