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.
Originally written in German — read it on visnakovs.de.
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:
| Variable | What it holds |
|---|---|
ecommerce.items | Product array |
ecommerce.value | Total value |
ecommerce.currency | Currency |
ecommerce.coupon | Coupon code |
ecommerce.tax | Tax |
ecommerce.shipping | Shipping cost |
ecommerce.transaction_id | Order number |
ecommerce.affiliation | Shop 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:
- Install and activate the plugin
- Enter your container ID
- Under Integration → WooCommerce: enable “Track Enhanced E-Commerce”
- 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
- Turn on GTM preview mode
- Walk the shop: view a product → add to cart → checkout → buy
- Check GA4 DebugView: are
view_item,add_to_cart,begin_checkoutandpurchasearriving?
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 on my German site: GTM configurator (in German). 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 containerWant e-commerce tracking set up properly rather than approximately? Write to me and I’ll take a look.