Skip to content

feat(analytics): capture landing attribution params on the init event - #306

Merged
Maozsm merged 1 commit into
base44:mainfrom
Maozsm:feat/analytics-landing-attribution
Oct 6, 2026
Merged

Maozsm merged 1 commit into
base44:mainfrom
Maozsm:feat/analytics-landing-attribution

Conversation

@Maozsm

@Maozsm Maozsm commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

What

__initialization_event__ now carries landing-URL attribution params next to referrer.

Why

page_url is location.pathname and the init event sends only document.referrer, so UTMs and ad click IDs on the landing URL never reach app_events as fields. Today they only show up by accident, inside properties.referrer after a full reload, or inside the __user_in_app__ URL, which has no session_id. So we can't attribute app visitors to paid Google, Meta or email traffic.

How

  • Reads a fixed allowlist from location.search at init: utm_source/medium/campaign/term/content/id, gclid, gbraid, wbraid, gad_source, gad_campaignid, fbclid, msclkid, ttclid, li_fat_id.
  • Allowlist only, never the full query string: landing URLs carry PII (e.g. utm_email) and tokens.
  • Empty values are skipped and each value is capped at 500 chars. Values are stored as-is.
  • No backend change: properties is a JSON column with a 50-key / 100KB limit, and this adds at most 15 keys.
  • The SDK's own URL rewrites (access_token, analytics-enable) delete only their own key, so the params are still there when init reads them.

Tests

3 new unit tests: allowlisted keys captured while utm_email, token and empty values are dropped; the 500-char cap; and referrer only when there are no params. They failed on main ({ referrer } only) and pass with the change.

🤖 Generated with Claude Code

__initialization_event__ sent only document.referrer, and page_url is
location.pathname, so UTMs and ad click ids on the landing URL never
reached app_events as fields. Read an allowlist of 15 keys (utm_*,
gclid/gbraid/wbraid, gad_*, fbclid, msclkid, ttclid, li_fat_id) from
location.search at init, skip empty values, cap each at 500 chars.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Maozsm
Maozsm merged commit 4399836 into base44:main Oct 6, 2026
4 of 7 checks passed
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.

2 participants