Skip to content

fix(analytics): Attribute Awin affiliate sales even when the server conversion fails - #841

Open
vitorrgg wants to merge 1 commit into
mainfrom
fix/awin-fallback-pixel-cks
Open

vitorrgg wants to merge 1 commit into
mainfrom
fix/awin-fallback-pixel-cks

Conversation

@vitorrgg

Copy link
Copy Markdown
Member

Why

Awin homologation for Tia Sônia (advertiser 128977) is blocked on the fallback pixel. The S2S conversion is validated and working, but Awin won't launch with S2S only: the sread.img fallback fires without the click id today, so if the S2S call ever misses, attribution falls back to Awin's third-party cookies, which browsers increasingly block. Awin confirmed sread.img accepts cks the same way sread.php does and asked for a testmode=1 firing to validate.

What

  • cks on the fallback pixel (vbeta-app.ts): the awc captured on the click landing is now sent as cks, so the fallback attributes the sale deterministically without depending on cookies.
  • Opt-in test session ?awin_testmode=1 (set-tracking-ids.ts): kept on sessionStorage, flows to /_analytics with the other tracking ids. On such a session:
    • the pixel fires with testmode=1;
    • the server skips the S2S call (send-to-awin.ts) — the Awin conversion REST API has no test flag, any order posted there is a real conversion (this is what forced the store to cancel the previous test order);
    • the pixel always fires, since it becomes the only channel.

Nothing here is temporary. The test flag is scoped to one browser session and is meant to be reused on any future Awin validation without touching code.

Verification

  • ESLint clean on the changed files (the 6 no-console warnings in vbeta-app.ts are pre-existing).
  • tsc --noEmit on packages/storefront and packages/ssr: no errors on the changed files (remaining output is the usual import.meta.env / alias noise outside Astro).
  • No automated test added: none exists for the analytics forwarders and emitAwinFallbackPixel isn't exported. Can be covered in a follow-up by extracting the URL builder.

Rollout

  1. Release → bump @cloudcommerce/* on tiasonia/functions/ssr → deploy.
  2. Click the Awin test affiliate link with &awin_testmode=1, place an order, confirm on DevTools that sread.img carries cks and testmode=1.
  3. Awin validates the fallback and signs off the full install.

🤖 Generated with Claude Code

…onversion fails

Send the captured click id (`awc`) as `cks` on the `sread.img` fallback
pixel, so a sale that misses the S2S call is still attributed
deterministically instead of relying on Awin third-party cookies. Awin
confirmed `sread.img` accepts `cks` the same way `sread.php` does.

Add an opt-in test session, marked with `?awin_testmode=1` and kept on
sessionStorage: the pixel then fires with `testmode=1` and the server
skips the S2S conversion, which has no test flag on the REST API and
would otherwise register a real order. On such a session the pixel
always fires, as it becomes the only tracking channel.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant