Published: 20 January 2025

GTM template: WordPress e-commerce tracking with GTM4WP & GA4

A free GTM container for WordPress e-commerce tracking via the GTM4WP plugin. One GA4 event tag and 18 dataLayer variables — already configured.

Daniils Visnakovs
· Reading time: 5 min

The WordPress plugin GTM4WP pushes e-commerce events into the dataLayer for you. What’s almost always missing is the other half — the piece inside GTM that picks those events up and sends them to GA4. That’s what this template is: one GA4 event tag and 18 dataLayer variables for complete e-commerce tracking.

What’s in the template

1 GA4 event tag

A single tag that reacts to every GTM4WP e-commerce custom event — from view_item through to purchase.

18 dataLayer variables

Every e-commerce parameter GA4 needs:

VariableWhat it holds
ecommerce.itemsProduct array
ecommerce.valueTotal value
ecommerce.currencyCurrency
ecommerce.couponCoupon code
ecommerce.taxTax
ecommerce.shippingShipping cost
ecommerce.transaction_idOrder number
ecommerce.affiliationShop name
…and 10 more

1 custom event trigger

Fires on all GTM4WP e-commerce events: view_item, add_to_cart, begin_checkout, purchase, and the rest.

Prerequisite: the GTM4WP plugin

The GTM4WP plugin has to be installed and configured:

  1. Install and activate the plugin
  2. Enter your container ID
  3. Under Integration → WooCommerce: enable “Track Enhanced E-Commerce”
  4. Set the dataLayer format to GA4

Setup

1. Import the template

Import container → upload the JSON → merge.

2. Enter your GA4 measurement ID

Put your G-XXXXXXX ID into the GA4 event tag. The e-commerce parameters are pulled from the dataLayer variables automatically.

3. Test it

  1. Turn on GTM preview mode
  2. Walk the shop: view a product → add to cart → checkout → buy
  3. Check GA4 DebugView: are view_item, add_to_cart, begin_checkout and purchase arriving?

Why one tag for everything

GTM4WP writes the event name straight into the dataLayer, and the tag takes it over as the GA4 event name — so you don’t need a separate tag per event. That keeps the container lean and maintainable.

Download the template

The configurator that generates this container is here: GTM configurator. The JSON it produces is language-neutral, so it works the same in any container.

Grab the container file below and import it into your Google Tag Manager container under Admin → Import Container. No sign-up, no email wall — it’s a plain file.

Downloadgtm-template-wordpress-ga4.jsonGTM container, ~20 KB — import it straight into your container

Want e-commerce tracking set up properly rather than approximately? Write to me and I’ll take a look.


Daniils Visnakovs

About the author

Daniils Visnakovs

Independent sparring partner for Google Ads economics and measurement quality. Daniils did technical measurement implementation work for Google. Today he helps teams make better decisions and keep the knowledge in-house: in 1:1 consulting, workshops or on stage.