# Track purchases

- Check 41.11 · Tracking and analytics setup · Critical
- Source: https://checklist-seo-geo.com/en/tracking-analytics-setup/track-purchases
- Send a single, complete purchase event to GA4 or Matomo from Shopify, WooCommerce, PrestaShop, Magento or Laravel, then reconcile it with the back office.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/tracking-analytics-setup/track-purchases.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

Tracking purchases means sending the analytics tool, once per order, an event that carries the order ID, its amount, its currency and the products bought. In GA4, this is the `purchase` event; in Matomo, an ecommerce order. Once this is done, you know revenue and the number of orders by source, by landing page and by product, including for organic search and AI assistants.

## Why it matters

For an online store, traffic and even conversion rate are not enough: two pages that convert equally well can bring in very different amounts. Revenue by source is the only measure that lets you compare SEO, AI assistants and paid campaigns on the same basis.

Purchase measurement problems are many and silent: an order counted twice when the customer reloads the confirmation page, an amount sent with a decimal comma or as text, a missing currency, a return from the bank or PayPal that overwrites the original source, a confirmation page never displayed when the customer closes the tab after paying. A wrong report looks just like a correct one; only reconciliation with the back office reveals it.

## What it improves

- **Organic revenue**: the basis of the task [track organic revenue](https://checklist-seo-geo.com/en/seo-kpis/track-organic-revenue).
- **Revenue from AI**: orders and amounts from visits identified as coming from ChatGPT, Perplexity or Copilot. See [measure identifiable AI visits, conversions and revenue](https://checklist-seo-geo.com/en/geo-kpis/measure-identifiable-ai-visits-conversions-revenue).
- **Product and category priorities**: landing pages that generate revenue, not just traffic.
- **Paid campaigns**: bidding based on the actual value of orders.
- **Rankings**: no effect.

## How to check

1. **Place a test order** (the payment provider's test mode, or a product at a token price refunded afterwards).
2. **Watch what is sent** with [Tag Assistant](https://tagassistant.google.com/): a single `purchase` event must be sent, with `transaction_id`, a numeric `value`, `currency` as an ISO code (`EUR`) and a non-empty `items` array.
3. **Reload the confirmation page**: no second `purchase` must be sent.
4. **Check reception** in `Admin > Data display > DebugView`, then 24 to 48 hours later in `Reports > Monetization`. For Matomo, see the `Ecommerce` report and the visits log.
5. **Reconcile** over a full month the number of orders and the revenue in the tool with those in the back office (see the last step).

## How to implement

### Before you start

Set four conventions and write them in the tracking plan:

| Question | Recommended convention |
|---|---|
| What does `value` contain? | The product amount after discounts, excluding shipping; `shipping` and `tax` separately. Or the full amount including tax: what matters is choosing and sticking to it. |
| Format | A number with a decimal point (`72.05`), never text or a currency symbol |
| Currency | ISO 4217 code (`EUR`, `CHF`, `CAD`) on every event |
| ID | The back-office order number, unique, with no personal data |

GA4 deduplicates `purchase` events that carry the same `transaction_id`. An empty or fixed ID skews everything: GA4 also deduplicates all purchases sent with an empty ID.

Next, declare the payment providers that send the customer back to your site: `Admin > Data streams > your stream > Configure tag settings > Show all > List unwanted referrals`, one condition per domain (`paypal.com`, the domain of your bank's 3-D Secure page, hosted payment provider). Otherwise, the order is attributed to PayPal and not to SEO. If payment goes through a domain you own, see [set up cross-domain tracking](https://checklist-seo-geo.com/en/tracking-analytics-setup/set-up-cross-domain-tracking-if-needed).

### With GA4 and gtag.js

On the confirmation page, generate the code server-side with the order data:

```js
gtag('event', 'purchase', {
  transaction_id: 'CMD-2026-10458',
  value: 64.50,
  tax: 10.75,
  shipping: 4.90,
  currency: 'EUR',
  items: [
    {
      item_id: 'THE-VERT-SENCHA-100',
      item_name: 'Organic Sencha 100 g',
      item_category: 'Green teas',
      price: 12.90,
      quantity: 5,
    },
  ],
});
```

Each item carries at least `item_id` or `item_name`, ideally both. For refunds, send `refund` with the same `transaction_id` (see below).

### With Google Tag Manager

The site pushes the purchase into the `dataLayer`, first clearing the previous ecommerce object as Google recommends:

```js
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: null });
window.dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: 'CMD-2026-10458',
    value: 64.50,
    tax: 10.75,
    shipping: 4.90,
    currency: 'EUR',
    items: [
      { item_id: 'THE-VERT-SENCHA-100', item_name: 'Organic Sencha 100 g', price: 12.90, quantity: 5 },
    ],
  },
});
```

In Tag Manager:

1. “Custom Event” trigger, event name `purchase`.
2. “Google Analytics: GA4 Event” tag, event name `purchase` (or the built-in `{{Event}}` variable for a tag shared by all ecommerce events).
3. Under “More Settings > Ecommerce”, tick “Send Ecommerce data”, data source “Data Layer”.
4. Preview, place a test order, then publish.

### With Matomo

First enable ecommerce for the site in Matomo's website management (`Administration > Websites > Manage`, the site's ecommerce option). Then, on the confirmation page:

```js
_paq.push(['addEcommerceItem', 'THE-VERT-SENCHA-100', 'Organic Sencha 100 g', 'Green teas', 12.90, 5]);
_paq.push(['trackEcommerceOrder', 'CMD-2026-10458', 80.15, 64.50, 10.75, 4.90, false]);
```

The order of the `trackEcommerceOrder` parameters is: ID, grand total (including tax and shipping, after discounts), subtotal, tax, shipping, discount. Amounts are numbers, not text. The unique ID prevents Matomo from counting the same order twice.

### Shopify

Versions: Shopify admin, Google & YouTube channel and Web Pixels API, all plans, November 2026.

- **GA4**: the Google & YouTube sales channel, linked to your property, sends the standard ecommerce events, purchase included. This is the recommended route; do not add a second GA4 tag in the theme or in a custom pixel for the same property.
- **Another tool (Matomo…)**: `Settings > Customer events > Add custom pixel`, then subscribe to `checkout_completed`. Shopify fires it once per order, usually on the thank-you page, or on the first post-purchase upsell page if there is one.

```js
analytics.subscribe('checkout_completed', (event) => {
  const checkout = event.data.checkout;

  window._paq = window._paq || [];

  checkout.lineItems.forEach((item) => {
    window._paq.push(['addEcommerceItem', item.variant?.sku || item.variant?.id, item.title, '', item.variant?.price?.amount, item.quantity]);
  });

  window._paq.push(['trackEcommerceOrder', checkout.order?.id, checkout.totalPrice?.amount]);
});
```

The Matomo loading code goes at the start of the same pixel.

### WordPress

Versions: WordPress 6.4 and later, WooCommerce 9 and later; Google Analytics for WooCommerce extension, November 2026 version.

With WooCommerce, install the free Google Analytics for WooCommerce extension, then go to `WooCommerce > Settings > Integration > Google Analytics` and enter the `G-…` Measurement ID. It sends purchases, add-to-cart events, checkout starts and product views, among others.

Only one source must send purchases: if the WooCommerce extension sends them, remove any `purchase` code from the theme and any purchase tag from Tag Manager, and check that another plugin (Site Kit, a marketing plugin) does not also send ecommerce events.

For Matomo, the Matomo Analytics plugin for WordPress offers WooCommerce order tracking; check in its settings that ecommerce tracking is turned on.

### PrestaShop

Versions: PrestaShop 8.2 and later; Google Analytics module (`ps_googleanalytics`), November 2026 version.

Install PrestaShop's Google Analytics module from `Modules > Module Manager`, open “Configure” and enter the `G-…` ID. The module supports GA4; its documentation states that some of the data (refunds in particular) depend on the ecommerce settings. Place a test order and check the `purchase` event in DebugView before relying on it.

### Magento

Versions: Magento Open Source and Adobe Commerce 2.4.5 and later.

`Stores > Settings > Configuration > Sales > Google API`, “Google GTag” section, “Google Analytics4” subsection: set “Enable” to “Yes”, enter the Measurement ID, then “Save Config” and flush the cache. Adobe's documentation does not detail which GA4 ecommerce events are sent: check the purchase with a test order, especially with external payment methods such as PayPal, for which Adobe reports limits in checkout tracking.

### Laravel

Versions: Laravel 11 to 13.

Send the purchase on the confirmation page, only once per order, by marking the order as sent:

```php
// app/Http/Controllers/OrderConfirmationsController.php
public function show(Order $order): View
{
    abort_unless($order->user_id === auth()->id(), 403);

    $shouldTrackPurchase = $order->purchase_tracked_at === null;

    if ($shouldTrackPurchase) {
        $order->update(['purchase_tracked_at' => now()]);
    }

    return view('orders.confirmation', [
        'order' => $order,
        'shouldTrackPurchase' => $shouldTrackPurchase,
    ]);
}
```

```php
// app/Models/Order.php
/** @return array<string, mixed> */
public function toAnalyticsPurchase(): array
{
    return [
        'transaction_id' => $this->reference,
        'value' => (float) $this->subtotal_after_discounts,
        'tax' => (float) $this->tax_total,
        'shipping' => (float) $this->shipping_total,
        'currency' => $this->currency,
        'items' => $this->lines->map(fn (OrderLine $line): array => [
            'item_id' => $line->sku,
            'item_name' => $line->name,
            'price' => (float) $line->unit_price,
            'quantity' => $line->quantity,
        ])->all(),
    ];
}
```

```blade
{{-- resources/views/orders/confirmation.blade.php --}}
@if($shouldTrackPurchase)
    <script>
        gtag('event', 'purchase', {{ Js::from($order->toAnalyticsPurchase()) }});
    </script>
@endif
```

Do not use `@json` with an array written directly in the directive: Blade splits its arguments on commas. `Js::from` encodes any value without this pitfall.

Add the `purchase_tracked_at` column (nullable timestamp) through a migration, with its `up` and `down` methods. The `transaction_id` remains the main safeguard; the column also prevents the event from being sent on every visit to the page.

### Refunds and orders never confirmed

- **Refunds**: send the `refund` event with the original `transaction_id`, the currency and the refunded amount. From the back office, this goes through the GA4 Measurement Protocol, which requires an API secret created in `Admin > Data streams > your stream > Measurement Protocol API secrets` and the visitor's `client_id`, to be stored with the order at the time of purchase.
- **Confirmation page not displayed** (a customer who closes the tab after paying): the order is not measured. The Measurement Protocol allows server-side sending, but it must then be the only source sending the purchase, or share exactly the same `transaction_id` as the tag.

### Reconcile with the back office

Every month, fill in this table:

| Month | Back-office orders | GA4 orders | Gap | Back-office revenue | GA4 revenue | Gap | Comment |
|---|---|---|---|---|---|---|---|
| September 2026 | 1,240 | 1,052 | −15% | €61,400 | €52,900 | −14% | Stable |
| October 2026 | 1,310 | 1,498 | +14% | €64,800 | €74,100 | +14% | Duplicates since the theme update |

Gap formula: `=(C2-B2)/B2`. A stable negative gap is explained by consent refusals, blockers and confirmation pages that were not displayed. A positive gap almost always indicates duplicate purchases: see [fix duplicate conversions](https://checklist-seo-geo.com/en/tracking-analytics-setup/fix-duplicate-conversions).

> **Warning:** compare like with like: the same time zones (the GA4 property's and the store's), the same treatment of tax and shipping, cancelled orders excluded on both sides.

## Common mistakes

- **Purchase sent every time the confirmation page loads**, with no `transaction_id` or with a different ID each time.
- **Amount as text** (`"64,50 €"`): GA4 and Matomo ignore it or count it as zero.
- **Missing currency**: GA4 can neither convert nor add up the amounts.
- **Two sources of purchases**: the WooCommerce extension plus Tag Manager, or the Google & YouTube channel plus a custom pixel.
- **Payment providers not declared**: PayPal or the bank show up as revenue sources.
- **Personal data** in `transaction_id` or in item names (the customer's email or name): prohibited by Google Analytics policies.
- **Never reconciling** with the back office.

## Frequently asked questions

### Why is GA4 revenue lower than my store's?

GA4 counts only orders whose confirmation page loaded the tag, for visitors who accepted measurement and do not block scripts. Customers who close the tab after paying, refuse cookies or use a blocker escape measurement. A stable negative gap is normal; a gap that changes suddenly or becomes positive signals a tagging problem.

### How do I stop an order from being counted twice in GA4?

Always send the order number in transaction_id: GA4 deduplicates purchase events that carry the same ID. Never leave this ID empty, because GA4 would then deduplicate all those purchases together. Also check that only one source sends purchases, for example the ecommerce extension or Tag Manager but not both, and test reloading the confirmation page.

### Should VAT and shipping be included in a purchase's value?

There is no mandatory rule: choose a convention and apply it everywhere. Many sites send the product amount after discounts in value, and put VAT and shipping in the tax and shipping parameters. What matters is reconciling the figures with the back office using the same convention; otherwise the measured gap means nothing.

### How do I attribute a sale to ChatGPT or Perplexity?

GA4 attributes the purchase to the session's source, or to that of the previous visit depending on the attribution model. If the visitor arrives by clicking a link in an AI assistant that passes on a referrer or a UTM parameter, the sale appears under that source. Many visits from assistants, however, arrive without a referrer and fall into direct traffic: these figures are a minimum, not a total.

## Resources

- [Google Analytics: Measure ecommerce (gtag.js and Tag Manager)](https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtag)
- [Google Analytics Help: Minimize duplicate key events with transaction IDs](https://support.google.com/analytics/answer/12313109?hl=en)
- [Google Analytics Help: Unwanted referrals](https://support.google.com/analytics/answer/10327750?hl=en)
- [Google Analytics: Send events with the Measurement Protocol](https://developers.google.com/analytics/devguides/collection/protocol/ga4/sending-events?client_type=gtag)
- [Matomo: Manually tracking ecommerce actions](https://matomo.org/faq/reports/advanced-manually-tracking-ecommerce-actions-in-matomo/)
- [Shopify: `checkout_completed` event](https://shopify.dev/docs/api/web-pixels-api/standard-events/checkout_completed)
- [WooCommerce: Google Analytics for WooCommerce documentation](https://woocommerce.com/document/google-analytics-integration/)
- [Adobe Commerce: Google Analytics](https://experienceleague.adobe.com/en/docs/commerce-admin/marketing/google-tools/google-analytics)
- [PrestaShop: `ps_googleanalytics` module](https://github.com/PrestaShop/ps_googleanalytics)

Next steps: [fix duplicate conversions](https://checklist-seo-geo.com/en/tracking-analytics-setup/fix-duplicate-conversions) and [segment conversions and revenue by market](https://checklist-seo-geo.com/en/multilingual-tracking-maintenance/segment-conversions-revenue-market).
