-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set utm_parameters to null if not already set #7692
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -52,6 +52,14 @@ const Layout = ({ | |||
posthog.setPersonProperties({ preferred_theme: (window as any).__theme }) | |||
} | |||
if (hash) scroll.scrollMore(-108) | |||
|
|||
posthog?.register_once({ | |||
utm_source: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not actually confident that this does the right thing.
What happens if user has 2 sessions, the first with a utm_source of null and a second with a utm_source of "foo"? I'm not confident that setting it to null the first is enough to prevent it from being set the second time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does. In the picture above I've tried 3 sessions:
- Visit http://localhost:8001/?utm_source=apples
- Visit http://localhost:8001/?utm_source=tomatoes
- Visit http://localhost:8001/?utm_campaign=buy-everything
The first page is going to set all UTM parameters to null
apart from utm_source
. If a link with utm_campaign
(example) is being visited in the future, the initial_utm_campaign
is going to stay null
, but the utm_campaign
value is being updated, since it will always show the latest visited campaign.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if the utm_campaign
is already set to something, visiting a normal URL without the utm_campaign
property is not going to reset the value to null
. I believe we want to keep it to the latest value to a real campaign instead of resetting it whenever visiting the page directly or organically? @andyvan-ph
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that makes sense - apologies I was not reading the table correctly before.
I think this behaviour is fine - though one could argue that setting any attribution property should overwrite them all. This would mean that you would end up with
$utm_campaign: "buy_everything"
$utm_source: null
$initial_utm_campaign: null
$initial_utm_source:"apples"
though it's understandable that this is out of scope for this PR, as it's beyond what is possible with how this is implemented atm
Changes
Apply this fix to posthog.com
A user following these URLs:
Will end up with these UTM properties: