Skip to content
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

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

MarconLP
Copy link
Member

@MarconLP MarconLP commented Feb 3, 2024

Changes

Apply this fix to posthog.com

A user following these URLs:
2024-02-03 at 20 04 37@2x
Will end up with these UTM properties:
2024-02-03 at 20 04 58@2x

Copy link

vercel bot commented Feb 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog ✅ Ready (Inspect) Visit Preview Feb 3, 2024 7:34pm

@@ -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,
Copy link
Member

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.

Copy link
Member Author

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:

  1. Visit http://localhost:8001/?utm_source=apples
  2. Visit http://localhost:8001/?utm_source=tomatoes
  3. 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.

Copy link
Member Author

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

Copy link
Member

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

@MarconLP MarconLP merged commit d04a617 into master Feb 6, 2024
2 checks passed
@MarconLP MarconLP deleted the set-default-utm-parameters branch February 6, 2024 06:02
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