PS PrestaShop Intermediate

Google Tag Pro (GTM & GA4) — Complete guide

Install, configure and check Google Tag Pro: Tag Manager container, GA4 e-commerce events, Consent Mode v2, Enhanced Conversions, container export, debugger and diagnostic, for PrestaShop 1.7.8, 8 and 9.

Updated Module version 2.0.0

Google Tag Pro (the dfgtagmanager module, version 2.0.0) loads your Google Tag Manager container and fills the dataLayer with the GA4 e-commerce events of the whole funnel. It sends the Google Consent Mode v2 default values before Tag Manager, pushes Enhanced Conversions data only after consent, writes each purchase once per order and exports a container that matches these events. A debugger, an event journal and a diagnostic of duplicate tags are built into the back office.

Requirements

  • PrestaShop 1.7.8, 8 or 9 (PHP 7.1 or later). Tested on 1.7.8.11 (PHP 7.4), 8.2.1 (PHP 8.1) and 9.1.5 (PHP 8.5), with the Classic and Hummingbird themes.
  • A Google Tag Manager web container (GTM-XXXXXXX) and a Google Analytics 4 property (G-XXXXXXXXXX).
  • A consent banner that sends Google Consent Mode updates, for example DataFirefly Cookie Manager (tarteaucitron) with its Google Consent Mode signals on.
  • Optional: Google Ads (conversion ID AW-… and label), Merchant Center, a server-side Tag Manager.

Installation and upgrade

  1. In Modules > Module Manager, click Upload a module and choose dfgtagmanager-2.0.0.zip.
  2. Open Improve > Google Tag Manager. A new installation loads nothing on the shop until you switch tracking on in the assistant.

Upgrade from 1.x: upload the new zip over the old module. Every setting is kept (only the new ones are added), the purchase history is merged into one line per order, and orders already shown by version 1.x are never sent again. If tracking was on, it stays on.

1. Setup assistant

Google Tag Manager setup assistant: steps, tracking status and figures of the purchases sent
Google Tag Manager setup assistant: steps, tracking status and figures of the purchases sent

The assistant lists six steps: container ID, consent, e-commerce data, Google Ads and Enhanced Conversions (optional), container import and a test visit. The panel on the right shows, over 30 days, the purchases sent, the share confirmed by the browser, the duplicates blocked, and the recovered purchases and refunds. Tracking stays off for visitors until you click Switch on for visitors: in the meantime only your debug browser receives the dataLayer.

2. E-commerce data

GA4 e-commerce data: prices with or without tax, Merchant Center item_id, categories, purchase recovery and refunds
GA4 e-commerce data: prices with or without tax, Merchant Center item_id, categories, purchase recovery and refunds
  • Prices and value: tax excluded (Google asks for value = sum of price × quantity, without shipping and tax) or tax included. The same choice applies to every event, from the lists to the refund.
  • Vouchers are spread over the item prices, so that price stays the discounted unit price and value stays the sum of the items. discount is the unit discount.
  • Currencies: each event uses the currency of the visitor, each purchase the currency of the order.
  • item_id: ID + separator + combination, ID + _ + combination, product ID, reference, EAN-13, UPC or MPN. Use the same format as the id of your Merchant Center feed. An empty reference falls back to the product ID.
  • Category path: item_category to item_category5, from the top category to the default category of the product. item_variant holds the combination (for example “M / White”).
  • Purchase recovery and refunds: see sections 6 and 7.
Google Consent Mode v2: default values before Tag Manager, region, detected cookie banner and code written in the page
Google Consent Mode v2: default values before Tag Manager, region, detected cookie banner and code written in the page

On every page, before Tag Manager, the module writes gtag('consent', 'default', …) with ad_storage, ad_user_data, ad_personalization and analytics_storage set to denied by default, and wait_for_update (500 ms by default).

  • Automatic (recommended): if your banner already sends its default values, the module sends none. With DataFirefly Cookie Manager and its Google Consent Mode signals on, Tag Manager loads right after the default values of the banner.
  • Always the module: the module always sends the default values; the banner sends the updates only.
  • Region: every visitor, or the European Economic Area, the United Kingdom and Switzerland only (region parameter).
  • ads_data_redaction is on; url_passthrough is off by default.

When the visitor chooses, the banner sends an update. The module follows every gtag('consent', 'update', …) and also offers:

window.dfgtm.update({
  ad_storage: 'granted',
  ad_user_data: 'granted',
  ad_personalization: 'granted',
  analytics_storage: 'granted'
});

The module sends the consent signals of Google; it does not decide what your shop must ask. Your consent banner and its settings remain your responsibility.

4. Google Ads and Enhanced Conversions

Google Ads and Enhanced Conversions: purchase conversion, Merchant Center, e-mail and phone hashed with SHA-256 after consent
Google Ads and Enhanced Conversions: purchase conversion, Merchant Center, e-mail and phone hashed with SHA-256 after consent

Enter the conversion ID and label to add a Google Ads purchase conversion and the Conversion Linker to the exported container. With a Merchant Center ID, the conversion also carries the items (cart data).

With Enhanced Conversions on, the confirmation page prepares the e-mail address and phone number of the order: lower case, spaces removed, dots removed before @gmail.com and @googlemail.com, phone in E.164, then SHA-256 (sha256_email_address, sha256_phone_number). The first name, last name, postal code and country can be added (off by default). This user_data is pushed only once ad_user_data is granted. No clear e-mail address appears in the page, the dataLayer, the journal or the requests of the module.

5. Events pushed to the dataLayer

Each e-commerce event is preceded by { ecommerce: null }.

Event When
view_item_list Listing pages (category, search, brand, best sales…) with the products really shown; home page and product blocks from the product miniatures; after an AJAX filter
select_item Click on a product miniature, with its list
view_item Product page and quick view
add_to_cart / remove_from_cart After each cart update (product page, quick view, cart page, quantity, deletion), from the real cart lines
view_cart Cart page, with the vouchers
begin_checkout Checkout, once per cart content
add_shipping_info Payment step reached, with shipping_tier (carrier)
add_payment_info Choice of a payment method, with payment_type
purchase Order confirmation page, once per order (transaction_id = order reference, tax, shipping, coupon, customer_type)
refund Credit slip or order refunded / cancelled after its purchase
search, login, sign_up Search page (an e-mail address typed in the box is never sent), sign-in, account creation
add_to_wishlist, view_promotion, select_promotion Wishlist button; banners carrying data-dfgtm-promotion-id

6. A purchase sent once per order

GA4 purchases: one per order, reloads of the confirmation page blocked, recovered and confirmed purchases
GA4 purchases: one per order, reloads of the confirmation page blocked, recovered and confirmed purchases

Each order has one line in the module. The purchase is written in the confirmation page only at its first display: a reload, the back button, a second tab or the return of a payment provider writes nothing and is counted as a blocked duplicate. The browser also keeps the transaction_id of each purchase pushed. Orders in error or cancelled send no purchase.

Reload of the confirmation page: purchase not pushed again, consent before Tag Manager, valid events
Reload of the confirmation page: purchase not pushed again, consent before Tag Manager, valid events

Recovery: if the confirmation page was never shown (payment provider without return) or was closed before Tag Manager loaded, the purchase is pushed once on the next page of the same customer, within 48 hours, with the same transaction_id. Google indicates that GA4 deduplicates purchase events with the same transaction ID.

7. Refunds

A credit slip sends a refund with the refunded items; an order moved to Refunded or Cancelled after its purchase sends a full refund (never after partial refunds). The refund is pushed at the next visit of the customer. Optionally, the Measurement Protocol can send it from the server: enter your own API secret (GA4 > Admin > Data streams > Measurement Protocol). It is used only for orders whose purchase was measured with analytics_storage granted, with the consent of that visit. Nothing else is sent from the server.

8. dataLayer debugger

dataLayer debugger: live test of the shop, each event arrives in the back office
dataLayer debugger: live test of the shop, each event arrives in the back office

Live test of the shop opens the shop in a new tab with a signed link valid two hours. Only that browser receives the dataLayer while tracking is off for visitors, and each event appears live in the back office.

Debug panel on the product page: add_to_cart with combination, discount and categories
Debug panel on the product page: add_to_cart with combination, discount and categories

On the shop, the panel lists every push with its JSON, the consent state and the checks of the page.

Checkout funnel: begin_checkout, add_shipping_info with the carrier and add_payment_info with the payment method
Checkout funnel: begin_checkout, add_shipping_info with the carrier and add_payment_info with the payment method
dataLayer preview of a product page: view_item and add_to_cart checked against the GA4 event reference
dataLayer preview of a product page: view_item and add_to_cart checked against the GA4 event reference

dataLayer of a page shows, without changing anything, what a product page, a category, the cart and the checkout, an order confirmation or a search would push, and checks each push against the GA4 event reference (items, currency when value is set, value = sum of the items, transaction_id…).

9. Event journal

Event journal: purchases, refunds, debug sessions and warnings, without any personal data
Event journal: purchases, refunds, debug sessions and warnings, without any personal data

The journal keeps the purchases written, the blocked duplicates, the recoveries, the refunds and the events of the debug sessions, with filters and the JSON of each line. It never holds an e-mail address or user_data. Lines older than the retention chosen in Settings (30 days by default) are deleted automatically. The Purchases tab shows the state of each order; the order page of the back office shows it too.

10. Container export

Tag Manager container export: Google tag, GA4 events, Google Ads conversion, triggers and consent per tag
Tag Manager container export: Google tag, GA4 events, Google Ads conversion, triggers and consent per tag

The export follows the format of a Tag Manager export: Google tag (GA4), one GA4 event tag fed by the dataLayer for the e-commerce events, search and login / sign_up tags, and, if set up, the Google Ads purchase conversion, the Conversion Linker and the User-Provided Data variable for Enhanced Conversions. Google tags keep their built-in consent checks; Meta, TikTok and Pinterest tags require ad_storage. No consent tag is included: the module writes the default values in the page.

  1. Click Download the container.
  2. In Tag Manager, open Admin > Import container, choose the file and a new workspace.
  3. Choose Merge and Rename conflicting tags, triggers and variables.
  4. Check the GA4 ID and the Google Ads label, test with Preview and the debugger of the module, then publish.

11. Diagnostic and other modules

Duplicate diagnostic: other Google Analytics or cookie banner modules and live analysis of a page
Duplicate diagnostic: other Google Analytics or cookie banner modules and live analysis of a page

The diagnostic reads, without changing them, the modules that may load Google tags or a banner:

  • the PrestaShop Google Analytics module (ps_googleanalytics) with an ID: visits counted twice;
  • DataFirefly All in One SEO, Tracking tab: same or other container, GA4 loaded directly, e-commerce events sent twice;
  • DataFirefly Cookie Manager: Google Consent Mode signals, Tag Manager or GA4 services of the banner;
  • other consent banners and modules whose name suggests Google tags.

The live analysis loads a page of the shop in the background and counts the Tag Manager and gtag.js loaders, the consent default commands and their order, duplicate events, missing ecommerce: null, invalid events and other trackers.

Troubleshooting

Nothing arrives in Tag Manager

Check that the container ID is valid, that tracking is on in the assistant and that the module is enabled in the module manager. Open a debug session: the Checks tab shows whether the consent default was sent and Tag Manager loaded.

Your banner does not send Google Consent Mode updates. Turn on its Google Consent Mode signals, or call window.dfgtm.update(…) when the visitor chooses.

add_to_cart is missing with another theme

The module relies on the standard PrestaShop events and product miniatures. Test with the debugger; a theme that does not emit updateCart is detected after a click on the add-to-cart button.

Visits are counted twice

Open the diagnostic: another module probably loads GA4 or Tag Manager too. Keep only one of the two.

Was this page helpful?

Still stuck? Contact support