# Tracking and conversions

URL: https://qrdx.dev/docs/tracking-and-conversions
Source: https://github.com/qrdxinc/qrdx/blob/main/apps/docs/content/docs/tracking-and-conversions.mdx

Add your analytics and retargeting pixels to hosted pages, see when and how people scan, and attribute sales and sign-ups to QR code scans.

Every [dynamic QR code](https://qrdx.dev/docs/dynamic-qr-codes) records scans without cookies. Tracking goes two steps further: load your own pixels on the hosted pages your codes open, and attribute conversions such as purchases on your website to the scan that brought the visitor. Use it when QR traffic has to show up in the tools your team already uses, or when you need to know which codes make money.

**Pixels on Pro, conversions on Business**

Tracking pixels are part of Pro and Business; conversion tracking is part of Business. Both are set up on the code's **Settings** tab. See [Plans and limits](https://qrdx.dev/docs/plans-and-limits).

Conversion tracking is under the QRdx commercial license. A self-hosted QRdx server needs a license key that QRdx issues with an enterprise agreement (`QRDX_EE_LICENSE`) to turn it on; see [Self-hosting](https://qrdx.dev/docs/self-hosting#optional-services). Pixels and scan analytics don't need one.

In a hurry? [See your scans](https://qrdx.dev/docs/help/dynamic-codes/scans) covers the analytics every plan has.

## How it works [#how-it-works]

A code either opens a hosted page or redirects to your website, and each path has its own tool. On a hosted page QRdx controls the HTML, so it can load your pixels after the visitor agrees. On your website QRdx controls nothing, so it hands your site a signed scan id in the URL and your site reports back when the visitor converts.

## Analytics on every code [#analytics-on-every-code]

Besides scans over time, countries, cities, devices, operating systems, browsers and referrers, each code's **Analytics** tab shows:

- **When people scan:** scans by hour of day and by weekday, in UTC or in your own time zone.
- **Languages:** each visitor's preferred browser language ("Unknown" when the browser doesn't send one).
- **A/B split:** scans per variant for each [A/B split rule](https://qrdx.dev/docs/smart-routing#ab-tests).
- **Page activity** (hosted pages): page views, unique viewers, taps and the most tapped links and buttons.
- **Conversions**, when the code has any.

![The When people scan card on a code's Analytics tab: scans by hour of the day and by weekday, as bar charts.](https://qrdx.dev/docs-static/shots/when-people-scan.light.webp)

**Codes** → **Analytics** in the sidebar adds up every code in the workspace: totals, scans over time, top codes, countries, devices, languages, scan times, and a comparison of up to 4 codes side by side. Bots and link previews aren't counted, a visitor counts once per day for "unique", and IP addresses are never stored.

## Tracking pixels on hosted pages [#tracking-pixels-on-hosted-pages-pro]

For codes that open a hosted page, the **Tracking pixels** panel on the code's **Settings** tab loads your own tags on that page:

| Provider | ID format |
| --- | --- |
| Google Analytics 4 | `G-` followed by 4 to 20 letters and digits |
| Meta (Facebook) pixel | 6 to 20 digits |
| TikTok pixel | 10 to 30 letters and digits |
| LinkedIn Insight Tag | Partner ID, 3 to 12 digits |

![The Tracking pixels panel on a hosted page code's Settings tab, with a Google Analytics 4 measurement ID and a Meta pixel ID filled in, the other pixel fields empty, and the cookie consent banner setting under them.](https://qrdx.dev/docs-static/shots/pixels-panel.light.webp)

Pixels only load when you set them up. Besides your pixels, the only script on a hosted page is QRdx's own page-activity counter, which reports views and taps to QRdx and to nobody else.

**Google Tag Manager** (`GTM-` followed by 4 to 12 letters and digits) loads only when the page opens on one of your [custom domains](https://qrdx.dev/docs/custom-domains). A container can run any script, so it never runs on qrdx.dev, where visitors may be signed in to QRdx.

### Consent [#consent]

Pixels never load before the visitor agrees:

- **Where required (EU, EEA, UK, Switzerland, unknown location)**, the default: visitors there, and visitors whose location is unknown, see a short banner naming your providers and choose **Accept** or **Decline**. The choice is remembered for that page, and **Cookie settings** lets them change it. Elsewhere pixels load right away, except for browsers that send the Global Privacy Control signal.
- **For every visitor:** everyone sees the banner first.

You remain responsible for your own privacy policy and for how you use the data your pixels collect. Codes that open your own website go there directly, so add your pixels to your site instead.

## Conversion tracking

Conversion tracking tells you which scans led to a sale, sign-up or any other goal, with revenue. It works for codes that open your website.

1. On the code's **Settings** tab, turn on **Conversion tracking**. Every scan then opens your URL with a signed `qrdx_sid` parameter added, for example `https://shop.example/?qrdx_sid=…`.
2. Add the snippet to the pages people land on and to the page where they convert:

```html title="Your website (before </body>)"
<script async src="https://qrdx.dev/conversions.js"></script>
<script>
  window.qrdx = window.qrdx || function () {
    (window.qrdx.q = window.qrdx.q || []).push(arguments);
  };
  // Where the conversion happens, for example your order confirmation page:
  qrdx("conversion", { name: "purchase", value: 49.99, currency: "USD", id: "ORDER-1234" });
</script>
```

The script remembers `qrdx_sid` in a first-party cookie on your domain for 30 days (add `data-storage="session"` to the script tag to keep it only for the browser session) and removes it from the address bar. Conversions are only sent for visitors who arrived from a scan, so other visitors are never tracked.

| Field | Meaning |
| --- | --- |
| `name` | What happened, for example `purchase` or `signup` (default `conversion`) |
| `value` | Amount, up to 2 decimals (optional) |
| `currency` | ISO 4217 code like `USD`; defaults to `USD` when a value is given |
| `id` | Your order or event id: sending the same id twice records it once |
| `metadata` | Up to 20 extra key/value pairs (optional) |

### Limits [#limits]

- A scan can be attributed for 30 days after it happened.
- `qrdx_sid` is signed, so it can't be guessed or changed to point at another code.
- Browser reports need conversion tracking to be on for the code, and each scan can report up to 10 conversions an hour. Reports from your server with a token have neither limit.
- Conversions stop being recorded if the workspace leaves Business; existing ones stay in your analytics, and turning tracking off is always possible.

## Limits and plans [#limits-and-plans]

| | Free | Pro | Business |
| --- | --- | --- | --- |
| Scan analytics, scan times, languages, page activity | Yes | Yes | Yes |
| Tracking pixels on hosted pages | No | Yes | Yes |
| Conversion tracking | No | No | Yes |

## For developers

To report conversions from your backend, which is more reliable than the browser, keep `qrdx_sid` with the order and call [`POST /v1/conversions`](https://qrdx.dev/docs/developers/api/create-conversion) with an [API key](https://qrdx.dev/docs/developers/api-keys) or an OAuth token that has the `codes:write` scope:

```bash title="Terminal"
curl -X POST https://api.qrdx.dev/v1/conversions \
  -H "Authorization: Bearer $QRDX_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"sid": "<qrdx_sid>", "name": "purchase", "value": 49.99, "currency": "USD", "id": "ORDER-1234"}'
```

The API answers `201` for a new conversion and `200` with `"duplicate": true` when the `id` was already recorded. With a token you can also send `"code": "<code id>"` instead of `sid` when the scan isn't known.

## Related [#related]

- [Smart routing](https://qrdx.dev/docs/smart-routing#utm-parameters): UTM parameters on every scan
- [Landing pages](https://qrdx.dev/docs/landing-pages): the hosted pages pixels run on
- [What QRdx records when someone scans](https://qrdx.dev/docs/help/privacy-and-security/scan-data)
