# Ad attribution

> Switch on Match sales to ads to keep the ad click behind a visit and a private customer key on each Shopify order, and learn what is stored and what stays.

This page explains the one switch that lets Clear Saga trace a sale back to the ad that earned it, so you can decide whether to turn it on and say so in your privacy notice.

> [!NOTE]
> The switch is off for every site until an Owner or Admin turns it on. While it is off, nothing new is read, sent or stored: no ad click and no customer key. Nothing is kept until you switch it on.

## What switching it on keeps

- **The ad click.** When a visitor arrives from an ad on Google, Meta, TikTok or Microsoft, the link carries a click id: `gclid`, `gbraid` or `wbraid` for Google, `fbclid` for Meta, `ttclid` for TikTok and `msclkid` for Microsoft. The script reads it from the page address, sends it once with the page view and forgets it. It sets no cookie and stores nothing in the browser for this. The UTM tag `utm_id` is read too. The rest of the address is never read. If the link carries more than one click id, one is kept, always chosen in the same order, so the same link gives the same answer.
- **A private customer key on each Shopify order.** When a connected [Shopify store](/docs/connect-shopify) reports an order from a customer it can identify, the order is stored with a key made from that customer. The key is a keyed hash, worked out with a secret only your site has, and written as a short code of letters and numbers. It is never the email and never the customer id, and neither of them is stored. Two orders from the same customer get the same key, which is all it is for.

Together they let a sale be traced to the ad click that earned it, and the customer key tells a first order from a returning one. The [store pages](/docs/store-summary) use both: [Which ads earned sales](/docs/which-ads-earned-sales) credits orders to ads, and [New customers](/docs/new-customers) counts new and returning customers. Reading the ad click needs the full script at `/js/script.full.js`: the light script never reads it. While the switch is on, the snippet under Settings, Installation loads the full script. If your site still uses the light one, copy the snippet again and replace the tag. The customer key does not depend on the script.

A change can take up to 5 minutes to reach your pages.

Your site is responsible for telling its visitors what it collects. This is not legal advice.

## Turn it on

1. Open the site, then Settings, Integrations.
2. Under **Ad attribution**, switch on **Match sales to ads**. It saves at once.
3. If your site loaded the light script, copy the snippet again under Settings, Installation and replace the tag on your site. The screen tells you when this is needed.

Only an Owner or Admin can open this tab and change it.

## Switch it off

Switching it off stops new collection, and the snippet goes back to the light script unless another option needs the full one. New page views no longer carry an ad click and new orders no longer get a customer key, within a few minutes. What was stored while it was on is kept: the ad clicks and customer keys already saved stay with their visits and orders.

## Ad platforms

Once the switch is on, Settings, Integrations also shows **Ad platforms**, the accounts that report what you spent on ads. The reports that use spend are built: the [Store summary](/docs/store-summary), [Which ads earned sales](/docs/which-ads-earned-sales), the [Creative report](/docs/creative-report) and the [Profit report](/docs/profit-report). They run on spend uploaded as a CSV under Settings, Costs, as [Costs and CSV upload](/docs/costs) explains, and on the seeded spend of the [public demo](/demo).

Connecting a Meta Ads, Google Ads, TikTok Ads, Pinterest Ads or Amazon Ads account is not available yet: see [what works today](/docs/status). Until then the list is read-only. Each connected account will show when it last synced, and ask you to sign in again if the platform revokes access.

The API, the MCP server and the command line can already list the connections of a site. See the [API reference](/docs/api).

**Next:** [Connect Shopify](/docs/connect-shopify) sends the orders, and [Privacy: cookieless by default](/docs/privacy) says what is stored.
