Skip to content

Add mm_attribution capture on Agent Wallet docs - #3057

Open
hieu-w wants to merge 1 commit into
mainfrom
feat/agent-wallet-attribution-cookie
Open

hieu-w wants to merge 1 commit into
mainfrom
feat/agent-wallet-attribution-cookie

Conversation

@hieu-w

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

Copy link
Copy Markdown

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
Writes a cross-subdomain tracking cookie with user-supplied query params; mitigated by whitelisting, sanitization, and size limits aligned with server-side attribution handling.

Overview
Adds last-touch marketing attribution on Agent Wallet doc landings so UTM and ad click IDs from the query string are stored in the shared mm_attribution cookie for developer.metamask.io to read later.

A new Docusaurus client module runs on route changes (skipping no-op navigations) and calls writeAttributionCookie, which only runs on paths containing /agent-wallet when at least one whitelisted UTM or click ID is present. The writer sanitizes and caps keys/values to match the developer dashboard and backend limits, merges with an existing cookie so new URL params win without dropping unrelated prior click IDs, sets Domain=.metamask.io, 90-day expiry, and Secure / SameSite=Lax. docusaurus.config.js registers the module alongside the existing scroll-fix client script.

Reviewed by Cursor Bugbot for commit 41c8252. 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 15, 2026 11:34am 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
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