# Installing Google Analytics 4 on a WooCommerce store

> On WooCommerce, GA4 can be installed three ways: a dedicated plugin, a snippet added to functions.php, or a Google Tag Manager container. What turns a clean install into a half-reliable one is the purchase event firing more than once on the thank-you page.

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

## Direct answer

> Pick one route only: a dedicated GA4 plugin, or a gtag.js snippet hooked to wp_head in the child theme functions.php. Two installations side by side produce double-counted purchases. The thing to watch is the thank-you page: woocommerce_thankyou runs again on every reload, so the purchase call must be limited to once per order, verified in DebugView.

## The situations I handle

- GA4 shows sessions but no ecommerce data in the purchase reports
- You’re torn between a dedicated GA4 plugin and a manual addition in functions.php
- The number of orders in GA4 is consistently higher than the real number of WooCommerce orders
- A native analytics feature from your hosting is being confused with Google Analytics 4
- You want to use Google Tag Manager but aren’t sure how to feed the WooCommerce data layer

## How I install GA4 on WooCommerce

1. **Choosing the installation method** — Depending on the site, I install a dedicated GA4 plugin that handles the WooCommerce data layer automatically, a gtag.js snippet in functions.php for a simple need, or a Google Tag Manager container when several marketing tools need to coexist.
2. **Checking for an existing tag** — I check the page source and the list of active plugins to make sure no other plugin is already sending data to Google Analytics alongside the planned install.
3. **Building the data layer across the purchase funnel** — I check that view_item, add_to_cart and begin_checkout fire with the expected parameters (items, value, currency) on the product page, the cart and the checkout page.
4. **Firing the purchase event once** — On WooCommerce’s thank-you page, I make sure purchase fires only once per order, with the correct transaction_id and value, even if the customer refreshes the page.
5. **Testing before going live** — I place a test order and check every event in Google Tag Manager’s preview mode or GA4’s DebugView before calling the install finished.

## Plugin, functions.php or GTM: how I decide

A dedicated GA4 plugin usually handles the WooCommerce data layer without touching any code, which suits most shops. A gtag.js snippet in functions.php is still useful for a one-off need, but every change means editing the theme again.

Be careful not to confuse GA4 with a native analytics feature that some hosts or WordPress plugins offer under a similar name: these are separate tools that don’t replace GA4 and don’t feed the same reports.

Underneath it all, WooCommerce needs to fire GA4’s recommended ecommerce events, view_item, add_to_cart, begin_checkout, purchase, with the names and parameters Google sets so the standard reports work. The purchase event in particular should fire once per order on the thank-you page, not on every page load.

## The most common duplication on WooCommerce

> A tracking plugin and a manual snippet both sending purchase for the same order artificially inflates the revenue GA4 measures. I always check that only one source sends each event before calling an install clean.

## Related pages

- **Google Tag Manager on WooCommerce** — The method I recommend for centralising GA4 and other marketing tools. ([/services/tracking/google-tag-manager-woocommerce](/services/tracking/google-tag-manager-woocommerce))
- **Ecommerce events that matter** — The GA4 events worth tracking first on a purchase funnel. ([/services/tracking/evenements-ecommerce-qui-comptent](/services/tracking/evenements-ecommerce-qui-comptent))
- **Duplicate stats: the causes** — Other common sources of duplication between plugins and manual tags. ([/services/tracking/doublons-statistiques-causes](/services/tracking/doublons-statistiques-causes))
- **WooCommerce, my main platform** — The other WooCommerce topics I deal with day to day. ([/wordpress-woocommerce](/wordpress-woocommerce))

## FAQ

### Dedicated GA4 plugin, functions.php snippet, or Google Tag Manager: which should I choose?

A dedicated plugin suits most shops without touching any code. I move to GTM as soon as several marketing tools (Ads, Meta, Pinterest) need to be added over time.

### How do I know if my site already sends data to Google Analytics?

I inspect the page source and the list of active plugins. A gtag.js tag or a GA4 ID (in the G-XXXXXXX format) visible in the code confirms a tag is already installed somewhere.

### Do I need consent before loading GA4?

GA4, in its standard configuration, doesn’t meet the CNIL’s exemption criteria for audience measurement tools. Loading it therefore, in principle, requires the visitor’s prior consent.

### Why are my purchases counted more than once in GA4?

It’s almost always the purchase event firing again when the thank-you page is refreshed, or a second source, a plugin and a manual snippet, sending the same event.

### Does a native analytics feature from my host replace GA4?

No, these are separate tools with different reports. I always check which one is actually configured before adding GA4 on top.
