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

Add feature to start new session on campaign change #1055

Open
denisov-vlad opened this issue Jan 27, 2022 · 3 comments
Open

Add feature to start new session on campaign change #1055

denisov-vlad opened this issue Jan 27, 2022 · 3 comments
Labels
category:browser About the browser-specific code. good first issue Good issue for a first time contributor. type:enhancement New features or improvements to existing features.

Comments

@denisov-vlad
Copy link

Is your feature request related to a problem? Please describe.
According to GA documentation it starts new session if referrer isn't equal URL domain or URL has UTM-params. It would be helpful to have the same logic inside Snowplow.

Describe the solution you'd like

  • Add function to start new session from code to have full control on it
  • Or / and add tracker parameter to force new session start if TLD(url) != TLD(referer) or URL has UTM-params

Thanks!

@denisov-vlad denisov-vlad added the type:enhancement New features or improvements to existing features. label Jan 27, 2022
@paulboocock
Copy link
Contributor

I don't think it's particularly well documented but the first bullet point already exists, you can call the newSession method to start a new session.

https://github.com/snowplow/snowplow-javascript-tracker/blob/master/trackers/browser-tracker/docs/markdown/browser-tracker.browsertracker.newsession.md

Or window.snowplow('newSession') if using the JavaScript Tracker rather than Browser Tracker.

I'll leave this issue open for the option to reset on UTM param change and/or new referer. That would perhaps be a breaking change though, or need to be disabled by default.

@paulboocock paulboocock added category:browser About the browser-specific code. good first issue Good issue for a first time contributor. labels Jan 27, 2022
@denisov-vlad
Copy link
Author

@paulboocock Thanks! That's exactly what I need.

But there is one issue with newSession usage from code when session timeout happens:

  1. Visit page (vid = 24)
  2. Wait for session timeout
  3. Call newSession before trackPageView (vid = 26)

@paulboocock
Copy link
Contributor

If you wait for the session to timeout and then visit the page, that's going to generate vid 25 immediately because that's a new session. Track Page View isn't when the session begins, when you arrive on the page and initialise the tracker is when the session starts.

In reality there are usually lots of edge cases when vid doesn't increase by only 1, it should be used to sort sessions in order, not to get a count of them (you should count by distinct domain_sessionid for that).

@paulboocock paulboocock changed the title Add feature to start new session from code Add feature to start new session on campaign change Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:browser About the browser-specific code. good first issue Good issue for a first time contributor. type:enhancement New features or improvements to existing features.
Projects
None yet
Development

No branches or pull requests

2 participants