https://www.growthbook.io/ logo
#announcements
Title
# announcements
e

early-midnight-28212

04/28/2022, 11:56 AM
Hello everyone, we currently have some AB tests done through GrowtBook but it seems we only get a sample of the data. E.g., we have a page that gets more 2 000 unique page views per week (based on Google Analytics and other sources) but Growthbook shows that we only have about 400 people in the AB test running on the page. Our GrowthBook is connected to GA and even metrics seem to work but the data is different. Any ideas why this could be? :)
f

future-teacher-7046

04/28/2022, 12:36 PM
When you added the GrowthBook SDK, what did you put for the trackingCallback?
e

early-midnight-28212

04/28/2022, 12:44 PM
Copy code
trackingCallback: (experiment, result) => {
            try {
                // @ts-ignore
                const localDataLayer = window?.dataLayer || [];

                const event = {
                    event: 'experiment',
                    experiment: experiment.key,
                    variation: result.variationId,
                    sessionId: pageProps?.sessionId || Cookie.get('sid'),
                };
                localDataLayer.push(event);
            } catch (error) {
                // silences the error in dev mode
            }
        },
f

future-teacher-7046

04/28/2022, 12:59 PM
If you look in GA do you see those events being fired the expected number of times?
It looks like you might be doing SSR with something like Next.js. window.dataLayer won't exist during the server render, so the tracking might not be working as expected.
9 Views