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.
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
-
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.
-
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.
-
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.
-
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.
-
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
-
Google Tag Manager on PrestaShop
The method I recommend for centralising GA4 and other tags without touching the theme every time.
-
Ecommerce events that matter
The GA4 events worth tracking first on a purchase funnel.
-
Conversions not showing up
The diagnostic method when purchases don’t appear in GA4 despite a tag being installed.
-
PrestaShop, my main platform
The other PrestaShop topics I deal with day to day.
Describe your need in one minute
A few targeted questions so I can reply with an estimate rather than another questionnaire.