For businesses
Measure sales from MacAd
The AdChanger tag tells AdChanger what happens on your website after someone clicks your MacAd bar: they arrived, stayed, looked around, added to cart or bought. A sale counts for your ad when it happens within 7 days of the last click on it.
How it works
When someone clicks your bar, the AdChanger app opens your link with a click ID added to it, for example ?mac=k3x9q2m7v4p8z1aa. The tag on your page reads that ID and reports what the visitor does, so the results in the app can show which clicks became customers.
- Visitors who did not arrive from a MacAd click are ignored: without a click ID the tag sends nothing.
- The tag loads without holding up your page, adds no visible element and never lets an error of its own reach your page.
- If a visitor clicks your bar more than once, the most recent click gets the credit.
Paste the tag
Put these lines in the <head> of every page of your website, or add them through your tag manager. Replace pk_your_key with your site key: in the AdChanger app, open Advertise, then Measure sales.
<script>
window.adchanger = window.adchanger || function () { (adchanger.q = adchanger.q || []).push(arguments); };
</script>
<script async src="https://adchanger.net/tag.js" data-key="pk_your_key"></script>The site key starts with pk_ and is made to sit in your page's code: it can only report events, and it cannot read your results. The first line lets you call adchanger() before the tag has finished loading; those calls are sent once it has.
With only these lines in place, the tag reports three things on its own:
- Arrived: the visitor reached your page from a MacAd click.
- Stayed 30 seconds: your page was on screen for 30 seconds (time in a background tab does not count).
- Looked around: the visitor scrolled at least half-way down the page, or opened a second page of your site.
If your site uses a Content Security Policy, allow https://adchanger.net/tag.js as a script source and https://adidmymsbpzrumtytsmg.supabase.co/functions/v1/measure/event as a connect source.
Mark add-to-cart and purchases
Call these where they happen: the first when something is added to the cart, the second on the page that confirms a finished order.
adchanger("add_to_cart");
adchanger("purchase", { order_id: "order-1234", value: 49.99, currency: "GBP" });- order_id: your own order number, up to 128 characters, so that AdChanger can tell one order from another and count each order once.
- value: the order total in ordinary units, such as 49.99. It is sent as minor units (4999).
- currency: GBP, USD or EUR. With any other currency the sale is still counted, without its value.
Send no names, email addresses or other details about the customer: the tag accepts only these three fields and drops anything else.
Shopify
Paste the tag into your theme (Online Store, Themes, Edit code, theme.liquid, inside <head>) so visits are measured.
Shopify does not run ordinary scripts on its checkout and order status pages. It runs custom pixels there instead, in a separate frame where the tag cannot see your shop's address. To report the sale there, add a custom pixel under Settings, Customer events, with the code below, and set its customer privacy permission to match your consent banner. It reads the click ID that the tag stored (so it reports sales only from visitors who gave consent) and sends the order number, total and currency.
analytics.subscribe("checkout_completed", async (event) => {
const mac = await browser.cookie.get("_adchanger_mac");
if (!/^[a-z0-9]{12,32}$/.test(mac || "")) return;
const checkout = event.data.checkout;
const sale = { kind: "purchase", at: event.timestamp, order_id: String(checkout.order?.id ?? checkout.token) };
if (["GBP", "USD", "EUR"].includes(checkout.currencyCode)) {
sale.value_minor = Math.round(Number(checkout.totalPrice.amount) * 100);
sale.currency = checkout.currencyCode;
}
fetch("https://adidmymsbpzrumtytsmg.supabase.co/functions/v1/measure/event", {
method: "POST",
keepalive: true,
headers: { "content-type": "text/plain" },
body: JSON.stringify({ key: "pk_your_key", mac, events: [sale] }),
});
});Sales from visitors who did not consent can still be reported from your server, as described next, for example with the discount code on your bar.
Sales the browser never sees
For sales made by phone, in an app, through a subscription renewal or anywhere the tag cannot run, your server can report the sale directly:
curl -X POST https://adidmymsbpzrumtytsmg.supabase.co/functions/v1/measure/conversion \
-H "Authorization: Bearer $ADCHANGER_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"idempotency_key": "order-1234",
"type": "purchase",
"occurred_at": "2026-10-07T14:30:00Z",
"click_id": "k3x9q2m7v4p8z1aa",
"value_minor": 4999,
"currency": "GBP"
}'- Authorization: your secret key, which starts with sk_. Keep it on your server only: never put it in a web page, an app or a public repository. If you think it has leaked, email yigit@adchanger.net at once.
- idempotency_key: use the same order number you pass as order_id to adchanger("purchase") on your site (here "order-1234"), so an order reported by both the tag and your server is counted only once. Sending the same key again never counts the sale twice, so a retry is safe.
- occurred_at: when the sale happened, as an ISO 8601 time.
- click_id or discount_code: the click ID (from your own records or the _adchanger_mac cookie), or the discount code on your bar that the customer used. One of the two is required.
- value_minor and currency: the total in minor units (4999 for 49.99) and GBP, USD or EUR.
Consent and privacy
Without consent, the tag reads the click ID from the page's address and reports what happens during that page view. It stores nothing on the visitor's device and reads nothing from it, so in our understanding it does not need cookie consent under the UK and EU rules on storage (PECR and the ePrivacy Directive). This is not legal advice: you remain responsible for your own consent banner and privacy notice.
Remembering a click across pages and days needs storage, so it needs consent. Only after consent does the tag set one first-party cookie on your domain:
- Name: _adchanger_mac. Value: the click ID and nothing else.
- Lifetime: 7 days, the attribution window. It is set only on the page the click arrived on, so it never extends the window.
- Scope: your site only (first-party, SameSite=Lax, Secure on https).
Tell the tag about consent in one of two ways: add data-consent="granted" to the tag's script element when your consent tool loads it only after consent, or call adchanger("consent", true) when the visitor agrees. If consent is given after the visitor arrived, the click is stored at that moment. Call adchanger("consent", false) when consent is withdrawn and the cookie is deleted.
The tag never uses local storage, never fingerprints a device and never sets third-party cookies.
What the tag sends
- Always: your site key, the click ID, the kind of event and its time.
- With some events: how many seconds the page was on screen, how far down it was scrolled, and for a sale its order number, value and currency.
- Like any request on the web, the request itself shows our servers (hosted by Supabase) the visitor's IP address and browser; the tag adds nothing more.
The tag never sends names, email addresses, postal addresses, phone numbers, card or bank details, what is on your pages, their addresses, or anything the visitor types.
In the app you see totals only, never individual visitors. How AdChanger handles personal data is set out in the privacy notice; the advertising side is on Advertise.