Available for projects & agency overflow · Quick reply, from the person who does the work

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.

Describe my issue Send a message

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.

Related pages

Describe your need in one minute

A few targeted questions so I can reply with an estimate rather than another questionnaire.

outil
api
sens
frequence (facultatif)
Please provide an email or a phone number so I can get back to you.

Please provide an email or a phone number so I can get back to you.

Frequently asked questions

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.