https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
f

famous-vegetable-72890

01/27/2023, 4:11 PM
Hi all I was wondering, has anyone tried using GrowthBook with https://getanalytics.io/ ? I have the basic setup working but I'm running in to trouble setting up experiments with the GrowthBook
trackingCallback
. Because of the way Analytics works I don't have direct access to the track methods at the point where I'm creating the GrowthBook instance. Does anyone know a work-around?
f

fresh-football-47124

01/27/2023, 4:11 PM
Hi Colin, looking into it
it looks like getAnalytics has a custom event function:
Copy code
analytics.track('experiment_viewed', {
  experiment_id: ...
  variation_id: ....
  ....
})
f

famous-vegetable-72890

01/27/2023, 4:13 PM
ah yeah so hold on I'll show you what I'm trying here:
Copy code
const growthbook = new GrowthBook({
  apiHost: "<https://cdn.growthbook.io>",
  clientKey: "XXXXXX",
  enableDevMode: true,
});

const analytics = Analytics({
  app: "experiment-testing",
  plugins: [
    mixpanelPlugin({
      token: "XXXXXX",
      options: {
        loaded: (mx) => {
          growthbook.setAttributes({
            ...growthbook.getAttributes(),
            id: mx.get_distinct_id(),
          });
        },
      },
    }),
  ],
  debug: true,
});
f

fresh-football-47124

01/27/2023, 4:14 PM
you’re using getAnalytics to track events to mixpanel?
f

famous-vegetable-72890

01/27/2023, 4:15 PM
so tracking events in components come from a track hook in analytics (it has a provider that wraps my app component taking the above
analytics
instance similar to the Growthbook one
oh wait, I can just call the tracking event manually on app startup right 🤦
ok i feel silly now 😄
thanks @fresh-football-47124 that makes sense. I was thinking this event needed to be passed into the callback at growthbook instance creation.
9 Views