Installing Google Tag Manager on a PrestaShop store
Google Tag Manager on PrestaShop means a container added once to the theme, after which every tag, GA4, Ads, Meta, is managed from the GTM interface with no new deployment. The prerequisite I install alongside it is a data layer fed by PrestaShop, or GTM has nothing to read.
The situations I handle
- You keep adding marketing tools and have to edit the theme every time
- GTM is installed but no tag fires correctly
- You’re not sure where to cleanly place the container’s two code snippets
- PrestaShop’s data layer is empty or incomplete on the cart and checkout
- Several people work on the site and the tracking code is duplicated in several places
How I install GTM on PrestaShop
-
Creating the GTM container
I create the container in the Google Tag Manager interface, which generates two code snippets: one for the head, one for right after the body tag opens.
-
Placing it in the PrestaShop theme
I place the first snippet in the theme’s head.tpl file, just before the closing </head>, and the second in the displayAfterBodyOpeningTag hook rather than hard-coded in a file copied onto every page.
-
Building the data layer
I have PrestaShop push product, cart and order variables (items, value, currency, transaction_id) at the right moment on the product page, cart and order-confirmation page, so GTM has data to read.
-
Adding tags from the GTM interface
Once the data layer is in place, I add GA4 and other marketing tags directly in GTM, without going back into the theme code.
-
Testing in preview mode
I check, page by page, which tags fire and with which data layer variables, before publishing the container to production.
Why go through GTM instead of hard-coding every tag
Without a tag manager, every new marketing tool, a Meta pixel, a Google Ads tag, means editing the PrestaShop theme and clearing the cache. With GTM, a single container is added once, and every following tag is managed from the interface, with no new deployment.
The container alone isn’t enough: GTM reads a data layer, a JavaScript data layer that PrestaShop needs to feed with product, cart and order information at the right time. Without a structured data layer, the ecommerce tags set up in GTM have nothing to read, even if the container itself is installed correctly.
I prefer placing both code snippets through theme files and PrestaShop’s native hooks rather than hard-coded across several copied templates, to keep a single point of maintenance.
Related pages
-
Google Analytics 4 on PrestaShop
The first tag to add once the GTM container is installed.
-
Duplicate stats: the causes
What happens when a GTM container is installed twice on the same page.
-
Checking a tag’s install without paid tools
Free tools to check a tag is actually firing.
-
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.