For businesses

Measure sales from MacAd

The AdChanger tag tells AdChanger what happens on your website after someone clicks your MacAd bar: they arrived, looked around, went on to another page, 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.

Your server's report is the one that counts. A sale only the tag reported is shown in your results separately, as reported by your site (not confirmed); it joins your confirmed sales, customers and return once your own server reports the same order. So for confirmed sales you need both steps: the tag on your site, and a report from your server.

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 these things on its own:

  • Arrived: the visitor reached your page from a MacAd click. Only a click's first arrival counts.
  • 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. Nothing else counts as looking around.
  • Went to a second page: the visitor clicked a link to another page of your site, your site moved to another page address without reloading (the tag wraps the browser's history.pushState to see this), or (with consent, see below) a later page of your site opened.
  • Interacted: the visitor first clicked, typed, touched the screen or selected a field, and how many seconds after arriving.
  • Left: how many seconds the page was on screen before the visitor first left it (switched to another tab or window, or closed it), sent once and never updated if they come back. A visit longer than 30 minutes is counted as 30 minutes. A visitor who leaves within a few seconds without going further is a bounce.

Arrival, second page, interaction and the 30 seconds count only within 30 minutes of the click, and leaving only for a visit that began within those 30 minutes, so a link shared and opened later is not counted as someone who engaged. Sales and add-to-carts still count for 7 days. To keep calls to our servers few, the tag sends the arrival at once and everything else together in one call when the visitor leaves the page; a sale is sent as soon as you report it.

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, purchases and sign-ups

Call these where they happen: the first when something is added to the cart, the second on the page that confirms a finished order, the third on any other thank-you page, such as a finished sign-up or trial. A conversion has no value, counts once per click, and shows in your report as the last step after visits and time on site.

adchanger("add_to_cart");

adchanger("purchase", { order_id: "order-1234", value: 49.99, currency: "USD" });

adchanger("conversion");
  • 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.

A sale the pixel reports is a site report: it is shown as reported by your site (not confirmed) until your server confirms the same order, as described next. Shopify's order webhooks can tell your server, or a developer's, when an order is placed or refunded, so it can send that report.

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.

Confirm sales from your server

Needed for confirmed sales. Your server reports each order to AdChanger, which makes it count in your sales, customers and return. It also covers sales made by phone, in an app, through a subscription renewal or anywhere the tag cannot run:

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": "USD"
  }'
  • Authorization: your secret key, which starts with sk_. Keep it on your server only, in an environment variable named ADCHANGER_SECRET_KEY as in the example: 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: one key per report. For a sale, use the same order number you pass as order_id to adchanger("purchase") on your site (here "order-1234"): that is how your server's report and the tag's report are known to be one order. 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. A very large order counts only up to a set limit, so one mistyped total can't distort your results.
  • order_id (optional): the order number, when your idempotency_key is something else. Order numbers are matched without spaces, a leading "#" or capitals, so "#1001" and "1001" are one order.

Order numbers: the tag's order_id and your server's order number must be the same order number for the two reports to meet. They are compared without surrounding spaces, a leading "#" or capitals; anything else must match exactly. If the two reports differ in value, your server's value is used.

Refunds and cancellations: send type "refund" (or "void") from your server with the order_id of the original sale and a new idempotency_key. The sale stops counting in your sales, customers and return. A refund can only be sent from your server, never from the tag, and it needs the order number: a sale reported without one cannot be taken back.

You decide whether the tag needs your visitors' consent, under the rules that apply to your website. In the UK and the EU, rules on storage and access (PECR and the ePrivacy Directive) can apply to tracking scripts even when no cookie is set: the European Data Protection Board's 2024 guidelines on the technical scope of these rules treat URL and pixel tracking as covered. The careful course in the UK and the EU is to load the tag only after consent, through your consent tool, and to report sales from visitors who did not consent from your server instead. This is not legal advice: you remain responsible for your own consent banner and privacy notice.

Without consent being signalled, the tag reads the click ID from the page's address and reports what happens during that page view; it sets no cookie. Remembering a click across pages and days needs storage, so the tag does that only after consent, with 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 many seconds until the first interaction, how far down it was scrolled, and for a sale its order number, value and currency.
  • Never which link was clicked or where the visitor went: a second page is reported as just that.
  • 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.