Skip to content

Add mm_attribution capture on Agent Wallet docs - #3057

Merged
chaitanyapotti merged 6 commits into
mainfrom
feat/agent-wallet-attribution-cookie
Sep 24, 2026
Merged

chaitanyapotti merged 6 commits into
mainfrom
feat/agent-wallet-attribution-cookie

Conversation

@hieu-w

@hieu-w hieu-w commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

Park last-touch UTMs and ad click IDs from /agent-wallet docs landings (including the quickstart) in the shared mm_attribution cookie (Domain=.metamask.io). This matches metamask.io so a later sign-in on developer.metamask.io can still attribute the campaign.

  • Only writes when the path includes /agent-wallet and the URL has at least one whitelisted UTM or click ID (utm_source, utm_medium, utm_campaign, utm_term, utm_content, plus gclid / twclid / fbclid / msclkid / ttclid / li_fat_id)
  • Last-touch merge: new URL params take the 10-key budget first; leftover slots keep earlier tags so a UTM-only visit does not drop a prior gclid
  • Sanitizes and caps keys/values to the same limits as the developer dashboard reader and backend
  • Cookie: 90 days, Secure, SameSite=Lax

This is site JS, not a documentation content change.

Issue(s) fixed

N/A

Preview

To verify: open the preview with ?utm_source=google&utm_medium=cpc&gclid=abc and confirm mm_attribution is set for .metamask.io. Localhost will not keep the cookie because of the shared domain.

Checklist

  • If this PR updates or adds documentation content that changes or adds technical meaning, it has received an approval from an engineer or DevRel from the relevant team.
  • If this PR updates or adds documentation content, it has received an approval from a technical writer.

External contributor checklist

  • I've read the contribution guidelines.
  • I've created a new issue (or assigned myself to an existing issue) describing what this PR addresses.

Note

Medium Risk
Introduces cross-subdomain marketing cookies and consent-dependent persistence; behavior is aligned with existing dashboard contracts but affects privacy-sensitive tracking flows.

Overview
Adds client-side last-touch campaign attribution for Agent Wallet docs so UTMs and ad click IDs from /agent-wallet URLs (e.g. quickstart with query params) are stored in the shared mm_attribution cookie on Domain=.metamask.io, matching metamask.io and readable later on developer.metamask.io.

A new Docusaurus client module runs on route updates and calls writeAttributionCookie, which only acts when the path includes /agent-wallet and the URL has whitelisted UTMs or click IDs (gclid, etc.). Values are sanitized and capped to dashboard/backend limits; merges prefer incoming URL params over an existing cookie so new tags are not dropped. Writes are gated on Osano MARKETING consent (immediate if already accepted, otherwise deferred until consent is saved); local dev without Osano does not persist the cookie.

Reviewed by Cursor Bugbot for commit 97fccc5. Bugbot is set up for automated code reviews on this repo. Configure here.

@hieu-w
hieu-w requested review from a team as code owners September 15, 2026 11:30
@vercel

vercel Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
metamask-docs Ready Ready Preview Sep 24, 2026 10:29am UTC

Request Review

@hieu-w hieu-w changed the title Capture Agent Wallet campaign tags in the shared mm_attribution cookie Add mm_attribution capture on Agent Wallet docs Sep 15, 2026
@hieu-w hieu-w closed this Sep 22, 2026
@hieu-w hieu-w reopened this Sep 24, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 97fccc5. Configure here.

Comment thread src/lib/attribution-cookie.js Outdated
…on logic

- Renamed `deferUntilConsent` to `watchConsent` for clarity.
- Updated the consent listener cleanup mechanism to prevent duplicate listeners.
- Added a new `deleteCookie` function to handle cookie deletion when consent is withdrawn.
- Enhanced comments for better understanding of consent lifecycle events.
@chaitanyapotti
chaitanyapotti merged commit 8be8eb9 into main Sep 24, 2026
18 checks passed
@chaitanyapotti
chaitanyapotti deleted the feat/agent-wallet-attribution-cookie branch September 24, 2026 12:17

This branch was successfully deployed

1 active deployment
Preview — da7aa6e0 Deployed Sep 24, 2026 by vercel[bot]
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.

3 participants