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

feat(web-analytics): Use fbclid to calculate channel type #27686

Merged
merged 7 commits into from
Jan 20, 2025

Conversation

robbie-c
Copy link
Member

@robbie-c robbie-c commented Jan 20, 2025

Problem

See https://posthoghelp.zendesk.com/agent/tickets/23328

Changes

Use fbclid in the calculation.

It's pretty low in the calculation, so it can't override UTM tags and known referrers, but if all else fails, this sets traffic with a fbclid to either Organic Social or Paid Social. (We can't know just from the fbclid whether it is paid or not, as meta adds fbclid to all URLs, not just paid).

Does this work well for both Cloud and self-hosted?

Yes

How did you test this code?

Added a test

@robbie-c robbie-c force-pushed the feat/use-fbclid-to-calculate-channel-type branch from 9fc152e to 889e1a0 Compare January 20, 2025 14:25
@robbie-c robbie-c marked this pull request as ready for review January 20, 2025 14:25
Comment on lines 271 to 276
has_gclid=ast.CompareOperation(
op=ast.CompareOperationOp.NotEq, left=aggregate_fields["$entry_gclid"], right=ast.Constant(value=None)
),
has_fbclid=ast.CompareOperation(
op=ast.CompareOperationOp.NotEq, left=aggregate_fields["$entry_fbclid"], right=ast.Constant(value=None)
),
Copy link
Member

Choose a reason for hiding this comment

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

Is this the right way to compare against NULL? My understanding is that Clickhouse behaves like Postgres and any comparison against NULL will return NULL. Does HogQL work around this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm I can just use the isNull function

Copy link
Member Author

Choose a reason for hiding this comment

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

Huh good catch, I am not sure why I thought clickhouse didn't do this
Screenshot 2025-01-20 at 14 35 01

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, anyway

@robbie-c robbie-c merged commit 1dd68dd into master Jan 20, 2025
92 checks passed
@robbie-c robbie-c deleted the feat/use-fbclid-to-calculate-channel-type branch January 20, 2025 16:31
zlwaterfield pushed a commit that referenced this pull request Jan 20, 2025
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
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