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

Referrer first and last touch #139

Merged
merged 2 commits into from
Nov 30, 2020
Merged

Referrer first and last touch #139

merged 2 commits into from
Nov 30, 2020

Conversation

timgl
Copy link
Collaborator

@timgl timgl commented Nov 30, 2020

Changes

Based on a conversation with a user, they were interested in knowing what last touch referrer led to a purchase. This wasn't possible, as we only set the referrer on the first page visit, but not on subsequent page visits within that session.

This correctly sets the $referrer and $referrer_domain in persistence so that it's always set to the last touch referrer.

In the interface this is how we explain this behaviour as well, but turns out we aren't doing this correctly:
image

cc @jamesefhawkins as you know more about first/last touch than me. Does this sound right to you?

Checklist

  • Tests for new code (if applicable)
  • TypeScript definitions (module.d.ts) updated and in sync with library exports (if applicable)

@timgl timgl requested a review from macobo November 30, 2020 11:47
package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "posthog-js",
"version": "1.7.1",
"version": "1.7.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? weird - not sure why this + featureflags.js tests are showing up here.

Maybe worth rebasing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Soz, hadn't pushed this from my hotfix this weekend. This is now in master and rebased. Feature flag is a legit small cleanup

@timgl timgl force-pushed the referrer-first-and-last-touch branch from 2c7a368 to 8b258cd Compare November 30, 2020 11:50
@@ -1,6 +1,6 @@
import { PostHogFeatureFlags } from '../posthog-featureflags'

fdescribe('featureflags', () => {
describe('featureflags', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is legit, cleaning up fdescribe left behind in atest

@@ -1,6 +1,6 @@
import { PostHogFeatureFlags } from '../posthog-featureflags'

fdescribe('featureflags', () => {
describe('featureflags', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is legit, cleaning up fdescribe left behind in atest

Copy link
Contributor

@macobo macobo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few small issues, otherwise lgtm.

Ideally we'd also cover user properties with a cypress-based smoke test as well but not necessary as part of this PR.


given('lib', () => Object.assign(new PostHogPersistence({ name: 'bla', persistence: 'cookie' }), given.overrides))

fdescribe('persistence', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe > fdescribe

@@ -0,0 +1,30 @@
import { PostHogPersistence } from '../posthog-persistence'

given('lib', () => Object.assign(new PostHogPersistence({ name: 'bla', persistence: 'cookie' }), given.overrides))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: given('persistence', () => new PostHogPersistence({ name: 'bla', persistence: 'cookie' })) - no need for overrides here (it's an artifact of core being stupid complex that it's even needed), this simplifies the test at hand.

@macobo macobo merged commit 57a5eb9 into master Nov 30, 2020
@macobo macobo deleted the referrer-first-and-last-touch branch November 30, 2020 12:28
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