wonderful-optician-39484
10/02/2024, 9:14 AMrhythmic-agent-34208
10/02/2024, 9:37 AMrhythmic-agent-34208
10/02/2024, 9:38 AMwonderful-optician-39484
10/02/2024, 9:58 AMrhythmic-agent-34208
10/02/2024, 10:14 AMwonderful-optician-39484
10/02/2024, 10:33 AMwonderful-optician-39484
10/02/2024, 10:35 AMrhythmic-agent-34208
10/02/2024, 10:52 AMwonderful-optician-39484
10/02/2024, 11:08 AMworried-monitor-77515
10/02/2024, 2:43 PMconst growthbook: GrowthBook = new GrowthBook({
apiHost: process.env.NEXT_PUBLIC_GROWTHBOOK_API_HOST || '',
clientKey: process.env.NEXT_PUBLIC_GROWTHBOOK_CLIENT_KEY || '',
// Enable easier debugging during development
enableDevMode: process.env.NEXT_PUBLIC_GROWTHBOOK_DEV_MODE === 'true',
// Update the instance in realtime as features change in GrowthBook
subscribeToChanges: true,
trackingCallback: (experiment, result): void => {
// eslint-disable-next-line no-console
console.log('Experiment Viewed', {
experimentId: experiment.key,
variationId: result.key,
})
window.dataLayer = window.dataLayer || []
window.dataLayer.push({
event: EventName.EXPERIMENT_VIEWED,
experiment_id: experiment.key,
variation_id: result.key,
})
},
})
rhythmic-agent-34208
10/03/2024, 3:14 PMrhythmic-agent-34208
10/03/2024, 3:15 PMworried-monitor-77515
10/03/2024, 3:17 PMrhythmic-agent-34208
10/04/2024, 8:27 AMworried-monitor-77515
10/08/2024, 9:03 AMworried-monitor-77515
10/08/2024, 9:03 AMrhythmic-agent-34208
10/08/2024, 9:37 AMrhythmic-agent-34208
10/08/2024, 9:37 AMworried-monitor-77515
10/08/2024, 9:49 AMSELECT
2 user_pseudo_id as anonymous_id,
Could this be the issue?rhythmic-agent-34208
10/08/2024, 10:58 AMworried-monitor-77515
10/08/2024, 11:02 AMrhythmic-agent-34208
10/09/2024, 8:39 AMworried-monitor-77515
10/09/2024, 8:41 AMworried-monitor-77515
10/09/2024, 8:41 AMworried-monitor-77515
10/09/2024, 8:42 AMrhythmic-agent-34208
10/09/2024, 11:14 AMrhythmic-agent-34208
10/09/2024, 11:14 AMrhythmic-agent-34208
10/09/2024, 11:14 AMrhythmic-agent-34208
10/09/2024, 11:14 AMworried-monitor-77515
10/09/2024, 11:20 AMworried-monitor-77515
10/09/2024, 11:21 AMrhythmic-agent-34208
10/09/2024, 11:22 AMworried-monitor-77515
10/09/2024, 11:23 AMworried-monitor-77515
10/09/2024, 11:24 AMvoid growthbook.setAttributes({
anonymous_id: anonymous_id,
deviceId: uuid,
userAgent: navigator.userAgent,
deviceType: /Mobi|Android|iPhone/i.test(navigator.userAgent)
? 'mobile'
: 'desktop',
browser: getCurrentBrowser(),
store: getStoreByLocale(router.locale ?? 'nl'),
hasOfficeIp: hasOfficeIpValue,
loggedIn: false,
})
worried-monitor-77515
10/09/2024, 11:24 AMrhythmic-agent-34208
10/09/2024, 11:25 AMworried-monitor-77515
10/09/2024, 11:26 AMrhythmic-agent-34208
10/09/2024, 11:47 AMworried-monitor-77515
10/14/2024, 9:14 AMrhythmic-agent-34208
10/14/2024, 10:27 AMrhythmic-agent-34208
10/14/2024, 10:28 AMworried-monitor-77515
10/14/2024, 11:02 AMrhythmic-agent-34208
10/14/2024, 11:06 AMworried-monitor-77515
10/14/2024, 11:08 AMif (typeof window !== 'undefined') {
window.dataLayer = window.dataLayer || []
window.dataLayer.push({
event: EventName.EXPERIMENT_VIEWED,
experiment_id: experiment.key,
variation_id: result.key,
})
}
rhythmic-agent-34208
10/14/2024, 3:32 PMwonderful-optician-39484
10/21/2024, 7:08 AMflaky-noon-11399
10/21/2024, 8:44 AMworried-monitor-77515
10/29/2024, 9:42 AMflaky-noon-11399
11/04/2024, 9:20 AMworried-monitor-77515
11/06/2024, 7:32 AMwonderful-optician-39484
12/05/2024, 7:14 AMwonderful-optician-39484
12/16/2024, 8:20 AMflaky-noon-11399
12/17/2024, 4:26 PMflaky-noon-11399
12/17/2024, 4:40 PMflaky-noon-11399
12/17/2024, 4:40 PMflaky-noon-11399
12/17/2024, 4:45 PMflaky-noon-11399
12/17/2024, 4:50 PMwonderful-optician-39484
12/18/2024, 8:01 AMwonderful-optician-39484
12/18/2024, 8:02 AMwonderful-optician-39484
12/18/2024, 8:02 AMworried-monitor-77515
12/18/2024, 8:05 AMflaky-noon-11399
12/18/2024, 12:22 PMbrief-honey-45610
12/18/2024, 10:26 PMbrief-honey-45610
12/18/2024, 10:28 PManonymous_id
and user_pseudo_id
while using GA4 with GrowthBook, in general you need to pass both of those attributes to the trackingCallback.
1. Set both identifiers as attributes when initializing GrowthBook:
javascript
growthbook.setAttributes({
id: user.id, // or generateAnonymousId() for logged-out users
anonymousId: getAnonymousId() // function to get GA4 client_id or user_pseudo_id
});
2. In your GA4 BigQuery setup, use an assignment query that includes both identifiers:
sql
SELECT
user_pseudo_id as anonymous_id,
user_id as id
FROM ...
3. When creating an experiment, choose which identifier to use for traffic splitting based on your needs. Use anonymous_id
for experiments that include both logged-in and logged-out users, and id
for experiments only targeting logged-in users.
4. Ensure you're passing both identifiers in your tracking callback to GA4. (As I mentioned just above.)
5. Set up identifier join tables in your GrowthBook data source to merge the identities during analysis. (This is what Natasha was asking about earlier.)
You might still see some multiple exposure warnings, especially if users transition from anonymous to a logged-in state.wonderful-optician-39484
12/19/2024, 8:26 AMbrief-honey-45610
12/19/2024, 8:45 PMI suppose it would suffice to only collect user_pseudo_id, right?You can use anything you want as the ID for assignment / hashing, as long as it is unique to each user.
If we name everything user_pseudo_id, that would also make everything more simple, I guess?Instead of using anonymous_id and user_pseudo_idYes.