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

future-petabyte-26077

01/13/2022, 2:28 AM
Has anybody integrated experiment tags with a 3rd party event platform (in my case, Segment)? I'm looking to add experiment tags to every single event that comes through instead of an ExperimentExposed event indicating when they either are included or see the screen/page/element/experience in question, and am looking for some precedence on how to keep it simple for our engineers.
f

future-teacher-7046

01/13/2022, 2:31 AM
Are you using analytics.js V2 or the old analytics.js from segment?
f

future-petabyte-26077

01/13/2022, 2:40 AM
We'll be implementing V2 in the next week or so
f

future-teacher-7046

01/13/2022, 2:57 AM
In that case, you can use the new middlewares feature. Something like this:
Copy code
analytics.addSourceMiddleware(
  function({ payload, next, integrations }) {
    const experiments = [];
    growthbook.getAllResults().forEach(function({experiment, result}) {
      experiments.push(experiment.key + "::" + result.variationId)
    });
    payload.obj.experiments = experiments;
    next(payload);
  }
)
17 Views