# 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.

- Source canonique : [https://allaux.fr/en/services/tracking/google-tag-manager-woocommerce](https://allaux.fr/en/services/tracking/google-tag-manager-woocommerce)
- Langue : EN
- Dernière mise à jour : 2026-09-30

## Direct answer

> Hook the first container snippet to wp_head and the second to wp_body_open from a child theme functions.php, so the installation survives parent theme updates. If code access is closed off, a GTM plugin does the same job from the WordPress admin. Only then populate the dataLayer on product, cart and woocommerce_thankyou pages.

## 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

1. **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.
2. **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.
3. **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.
4. **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.
5. **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.

## The risk of stacking plugins

> A tracking plugin often sets its own Google Analytics tag on top of the GTM container already installed. Before any install, I check the list of active plugins to spot ones already sending measurement data.

## Related pages

- **Google Analytics 4 on WooCommerce** — The first tag to configure once the GTM container is installed. ([/services/tracking/google-analytics-4-woocommerce](/services/tracking/google-analytics-4-woocommerce))
- **Duplicate stats: the causes** — What happens when several plugins send the same data. ([/services/tracking/doublons-statistiques-causes](/services/tracking/doublons-statistiques-causes))
- **Meta pixel and conversions API on WooCommerce** — Meta tracking follows the same logic: avoiding duplication between pixel and plugin. ([/services/tracking/pixel-meta-api-conversions-woocommerce](/services/tracking/pixel-meta-api-conversions-woocommerce))
- **WooCommerce, my main platform** — The other WooCommerce topics I deal with day to day. ([/wordpress-woocommerce](/wordpress-woocommerce))

## FAQ

### Should I edit functions.php directly or use a child theme?

Always a child theme. Editing the parent theme directly means losing the container the next time the theme updates.

### Is a dedicated GTM plugin as good as a manual install?

It simplifies things when code access is limited, but I keep an eye on what it actually adds: some also set their own tags alongside the container, which creates duplication.

### How many tracking plugins should a WooCommerce shop have?

Ideally a single GTM container centralising everything. Every extra plugin setting its own tag is a duplication risk and extra loading weight.

### How do I check the WooCommerce data layer is properly fed?

Google Tag Manager’s preview mode shows the data layer’s content on every page, making it easy to spot straight away if a variable like value is empty on the thank-you page.

### Do I need consent before GTM fires the tags?

GTM itself collects nothing, but the tags it fires, GA4 in particular, don’t meet the CNIL’s exemption criteria in their standard configuration and therefore, in principle, require the visitor’s prior consent.
