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

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.

Describe my issue Send a message

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.

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

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.