Installing Google Tag Manager on a WooCommerce store
On WooCommerce, I install the Google Tag Manager container in the theme (functions.php or a child theme), or through a dedicated plugin when code access is limited. Either way, everything then depends on a properly built WooCommerce data layer.
The situations I handle
- Several tracking plugins are installed, each setting its own tags
- You want to centralise GA4, Meta and Google Ads without stacking plugins
- The GTM container is installed but the ecommerce tags receive no data
- You’re torn between editing functions.php directly and using a child theme
- The site slows down after adding several tracking plugins
How I install GTM on WooCommerce
-
Creating the GTM container
I create the container in the Google Tag Manager interface, which generates two code snippets to place in the head and right after the body tag opens.
-
Placing it in the WooCommerce theme
I place the first snippet via the wp_head hook and the second via wp_body_open, in a child theme’s functions.php rather than the parent theme, so the install survives theme updates.
-
Alternative with a dedicated plugin
When code access is limited or the site changes hands often, I install the container via a dedicated GTM plugin, which handles the same thing from the WordPress admin.
-
Building the WooCommerce data layer
I have product, cart and order variables (items, value, currency, transaction_id) pushed at the right moment on the product page, cart and thank-you page, so GTM has data to read.
-
Adding tags and testing
I add GA4 and other marketing tags in the GTM interface, then check they fire correctly in preview mode before publishing the container.
Why centralise rather than stack plugins
It’s common to find, on a WooCommerce shop taken over from someone else, three or four tracking plugins installed over time, each setting its own Google Analytics or Meta tag. The result: redundant tags, events counted more than once, and a slower site.
Using a single GTM container means managing GA4 and other tags from one interface, without stacking plugins that each add their own code. I always start a GTM install with a clean-up: disabling redundant tracking plugins before adding the container.
The container alone isn’t enough: without a structured WooCommerce data layer, fed with product, cart and order information at the right time, the ecommerce tags set up in GTM have nothing to read.
Related pages
-
Google Analytics 4 on WooCommerce
The first tag to configure once the GTM container is installed.
-
Duplicate stats: the causes
What happens when several plugins send the same data.
-
Meta pixel and conversions API on WooCommerce
Meta tracking follows the same logic: avoiding duplication between pixel and plugin.
-
WooCommerce, my main platform
The other WooCommerce topics I deal with day to day.
Describe your need in one minute
A few targeted questions so I can reply with an estimate rather than another questionnaire.