Skip to content

Commit 67f438b

Browse files
Avoid incorrect session attribution. (tldraw#6544)
My understanding is that were were setting a property called `source` when sending over the events. Since there was no other source set then GA4 took this as the traffic source attribution as well. So the problem is not actually using UTM tags for internal navigation. The problem was that were we using the same name of the property that GA4 uses for traffic attribution. ### Change type - [x] `bugfix`
1 parent 8c74738 commit 67f438b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

apps/dotcom/client/src/utils/analytics.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ function getGA4() {
178178

179179
export function trackEvent(name: string, data?: { [key: string]: any }) {
180180
getPosthog()?.capture(name, data)
181+
182+
// For GA4, rename 'source' to 'event_source' to avoid session attribution
183+
if (data) {
184+
const { source, ...rest } = data
185+
data = source !== undefined ? { ...rest, event_source: source } : rest
186+
}
181187
getGA4()?.event(name, data)
182188
}
183189

0 commit comments

Comments
 (0)