Hi all I was wondering, has anyone tried using Gro...
# ask-questions
f
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
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
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
you’re using getAnalytics to track events to mixpanel?
f
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.