Repository navigation
feat(analytics): capture landing attribution params on the init event - #306
Merged
Merged
Conversation
__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>
arosenan
approved these changes
Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
__initialization_event__now carries landing-URL attribution params next toreferrer.Why
page_urlislocation.pathnameand the init event sends onlydocument.referrer, so UTMs and ad click IDs on the landing URL never reachapp_eventsas fields. Today they only show up by accident, insideproperties.referrerafter a full reload, or inside the__user_in_app__URL, which has nosession_id. So we can't attribute app visitors to paid Google, Meta or email traffic.How
location.searchat init:utm_source/medium/campaign/term/content/id,gclid,gbraid,wbraid,gad_source,gad_campaignid,fbclid,msclkid,ttclid,li_fat_id.utm_email) and tokens.propertiesis a JSON column with a 50-key / 100KB limit, and this adds at most 15 keys.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,tokenand empty values are dropped; the 500-char cap; andreferreronly when there are no params. They failed on main ({ referrer }only) and pass with the change.🤖 Generated with Claude Code