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

Installing Google Analytics 4 on a PrestaShop store

There are two ways to add Google Analytics 4 to PrestaShop: the gtag.js tag pasted straight into the theme, or a Google Tag Manager container, which I use by default so I don’t have to touch the code every time something changes. Either way, what breaks ecommerce tracking is a purchase event that isn’t filled in properly on the order confirmation page.

Describe my issue Send a message

The situations I handle

  • No ecommerce data reaching GA4 despite a tag visible in the page source
  • A PrestaShop module already sends data to Google Analytics and you want to add GA4 without duplicating it
  • GA4 reports show page views but no purchases
  • You’re not sure whether to hard-code gtag.js in the theme or use Google Tag Manager
  • The number of transactions in GA4 never matches the real number of PrestaShop orders

How I install GA4 on PrestaShop

  1. Choosing the installation method

    I add either the gtag.js tag directly in header.tpl or via a hook such as displayHeader, or a Google Tag Manager container that calls GA4 from its interface. I use GTM by default: future changes don’t require touching the theme again.

  2. Checking for an existing tag

    Before adding anything, I check the page source and the list of installed modules under Modules > Module Manager to make sure no third-party module is already sending data to Google Analytics.

  3. Checking the data layer on key pages

    I check that view_item, add_to_cart and begin_checkout fire with the right parameters (items, value, currency) on the product page, the cart and the checkout.

  4. Configuring the purchase event

    On PrestaShop’s order-confirmation page, I make sure transaction_id (the order ID) and value (the amount actually paid) are passed correctly, otherwise GA4 records a visit with no usable transaction.

  5. Testing before going live

    I check every event fires correctly in Google Tag Manager’s preview mode, or with the Tag Assistant extension if the tag is hard-coded, against a test order.

The two methods, and why I favour GTM

The gtag.js tag can be pasted straight into the PrestaShop theme, usually in header.tpl or via a hook such as displayHeader. That works, but every change, adding an advertising tool or editing an event, means touching the code and clearing the Smarty cache.

Using Google Tag Manager means adding a single container once, then managing GA4 and other tags from the GTM interface, with no new deployment for each change. Google recommends this approach for sites whose tracking is likely to evolve.

GA4’s recommended ecommerce events, view_item, add_to_cart, begin_checkout, purchase among others, have names and parameters set by Google: following them exactly is necessary for GA4’s standard ecommerce reports to work.

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

Do I have to use Google Tag Manager, or is hard-coded gtag.js enough?
Hard-coded gtag.js works fine for a simple install. I’d avoid it as soon as the site plans to add Google Ads, Meta or another tool: GTM saves you touching the theme every time.
Does Google Analytics 4 replace Universal Analytics?
Yes. Universal Analytics has stopped collecting data since July 2023. If an old PrestaShop module still points to it, nothing gets recorded any more.
Do I need visitor 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, like any non-exempt tracker.
How do I check my ecommerce events are configured correctly?
Google Tag Manager’s preview mode or GA4’s DebugView show, in real time, which events fire and with what parameters, page by page, during a test order.
Is a free PrestaShop tracking module enough on its own?
Some modules add a basic GA4 tag without full ecommerce events. I always check what a module actually sends before relying on it or adding to it.