PrestaShop
Tracking on PrestaShop via Google Analytics 4 – the tracking code in the theme and the official ps_googleanalytics module. No module from us yet.
PrestaShop is tracked via the Google Analytics route: the tracking code sits on every page, and PrestaShop's official Google Analytics module sends the purchase to Google Analytics 4 from the order confirmation – with order ID, amount, tax and shipping. The tracking code reads that, and we calculate commission on the goods excluding VAT and shipping.
Before you start
- Access to the theme (or a "custom code" module) and to Modules.
- The snippets from Program → Setup in Affilyflow, where your store ID is already filled in. In this guide,
DIN_BUTIKstands for your store ID. - Setup usually recognises PrestaShop on its own. If it is not selected, choose PrestaShop under Other systems.
Step 1: The tracking code on every page
PrestaShop has no field for head code in the admin itself. There are two routes:
- A custom code module from Addons that adds code to the head on every page. The easiest route without a developer.
- The theme: add the code to the head template (in the Classic theme,
templates/_partials/head.tpl) or register the script underassetsin the theme'stheme.yml. Theme changes can be overwritten by a theme update – a child theme holds up better.
<script src="https://app.affilyflow.com/t/DIN_BUTIK.js" async></script>After every theme update, check in Setup that the tracking code is still found. If you don't have access to the theme, send the guide to your developer with Send to developer in Setup.
Step 2: Switch on Google Analytics 4
Install and enable PrestaShop's official Google Analytics module (ps_googleanalytics) under Modules → Module Catalog, and enter your Measurement ID (G-…). The module sends purchase to Google Analytics 4 from the order confirmation with transaction_id, value, tax, shipping and currency. Another GA4 module works too, as long as it sends the purchase event.
How we calculate: PrestaShop sends shipping including VAT, and tax as all of the VAT. The base is therefore value − shipping (the goods including VAT) multiplied by (value − tax) / value – the goods excluding VAT and shipping, after discount. Setup stores this rule on the store when you choose PrestaShop – there is nothing for you to configure.
Without consent to statistics cookies, Google Analytics sends nothing, and we can't see that purchase.
For developers: without Google Analytics
If you don't want to use Google Analytics, a developer can add the sale line to the theme's order-confirmation.tpl. Here the order number is the reference, as you know it. The amount is the total minus shipping (variables from the Classic theme's order presenter), and data-affilyflow-vat removes the VAT – 25 is the Danish rate, change it to yours.
<div hidden data-affilyflow-order="{$order.details.reference}" data-affilyflow-total="{$order.totals.total.amount - $order.subtotals.shipping.amount}" data-affilyflow-vat="25" data-affilyflow-currency="{$currency.iso_code}"></div>The variable names have not been verified on a real store – check the amount in the live test. Use one route only: the line or Google Analytics – otherwise the same purchase can be reported twice, each time with a different order number (reference and ID).
Step 3: Test
Go to the Test tracking step in Setup, press Open test link and place a test order in the tab that opens – accept statistics cookies in the banner. Stay in Setup – the live test shows the test click and the purchase with order ID and amount, and asks whether the amount is right. A test purchase gives no commission and no fee. A purchase without a click from a link is not counted.
If you take payment with a redirect (MobilePay, Quickpay …), check that the customer lands on the order confirmation afterwards – if the customer never comes back to order-confirmation, the purchase isn't sent. See also Testing and troubleshooting.
Common problems
| What you see | Cause |
|---|---|
| Setup can't find the tracking code | The theme has been updated, and the change in the head is gone. Use a child theme or a custom code module. |
| Clicks, but never sales | Google Analytics 4 isn't switched on, the customer declined statistics cookies, or the customer never landed on the order confirmation after paying. |
| You can't find the sale in the admin | We show id_order, not the reference. Search for the ID under Orders. |
Refunds
PrestaShop doesn't report refunds or credit slips to us. You need to reject a refunded purchase yourself within the approval period – see Approval and refunds.
Missing something?
Write to us – we answer quickly, and the page gets fixed.