Shopware 6
Tracking on Shopware 6 via Google Analytics 4 – the tracking code in the theme and Google Analytics on the sales channel. The standard confirmation page is read even without Google Analytics. No app from us yet.
Shopware 6 is tracked via the Google Analytics route: the tracking code sits on every page, and Shopware's built-in Google Analytics sends the purchase to Google Analytics 4 from the order confirmation – with order number, amount, tax and shipping. The tracking code reads that, and we calculate commission on the goods excluding VAT and shipping. Shopware's standard confirmation page also writes the same figures into the page's HTML, and the tracking code reads them directly – so the purchase is reported even when Google Analytics isn't running.
Before you start
- Access to the theme (or a developer) and to the sales channel settings.
- 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 Shopware on its own. If it is not selected, choose Shopware 6 under Other systems.
Step 1: The tracking code on every page
Shopware has no field for head code in the admin itself. Add the code to your theme (for example by extending storefront/layout/meta.html.twig in the theme's base template) or through a plugin or app that adds a script to every page.
<script src="https://app.affilyflow.com/t/DIN_BUTIK.js" async></script>The code must be on every page of the sales channel affiliates link to – including checkout and the order confirmation (frontend.checkout.finish.page). Shopware Cloud stores can't install plugins; there, the theme or an app is the route. 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 on the sales channel
Go to Sales Channels → your storefront → Analytics, enter your Measurement ID (G-…) and save. Shopware sends purchase to Google Analytics 4 from the order confirmation without any extensions – with transaction_id (the order number you see in the admin), value, tax, shipping and currency.
How we calculate: Shopware sends shipping including VAT (gross for B2C) 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 Shopware – there is nothing for you to configure.
Without Google Analytics: the standard confirmation page writes data-order-number and a hidden element with data-value, data-tax, data-shipping and data-currency into the page. The tracking code reads them directly, using the same rule as the Google Analytics event, and reports the same order only once. Shopware's Google Analytics only starts after cookie consent; the direct reading follows the tracking code's own consent rules (see Consent and cookies).
For developers: if the theme lacks the elements
If your theme lacks the elements on the confirmation page, a developer can add the sale line to the theme's finish template (storefront/page/checkout/finish). positionPrice is the goods without shipping; whether it includes VAT depends on the customer group (gross for B2C). data-affilyflow-vat removes the VAT – 25 is the Danish rate, change it to yours, and remove it for a net customer group.
<div hidden data-affilyflow-order="{{ page.order.orderNumber }}" data-affilyflow-total="{{ page.order.price.positionPrice }}" data-affilyflow-vat="25" data-affilyflow-currency="{{ page.order.currency.isoCode }}"></div>The line has not yet been verified on a real store – test it with a test purchase and check the amount in the live test. Use one route only: the line or Google Analytics – otherwise the same purchase can be reported twice.
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. Stay in Setup – the live test shows the test click and the purchase with order number 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 the sale doesn't appear: check that the tracking code is on the order confirmation page too, and – if you rely on Google Analytics alone – that the Measurement ID is set on the right sales channel and that you accepted statistics cookies. See also Testing and troubleshooting.
Common problems
| What you see | Cause |
|---|---|
| Setup can't find the tracking code | The code is in a different theme from the one the sales channel uses, or the theme hasn't been recompiled. |
| Clicks, but never sales | The tracking code is missing from the order confirmation, or the theme has removed the confirmation page's hidden elements and Google Analytics is switched off. |
| The amount is too high for B2B customers | Net customer groups send amounts excluding VAT. Write to us – we will adjust the VAT rule for the store. |
Refunds
Shopware doesn't report refunds 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.