We have recently integrated Amplitude analytics and have more recently been testing Amplitude Experiments on our website. For our first test experiment, the ratio between assignment and exposure is roughly 2:1, so there is double the amount of assignments as there is exposures and we don’t know why that is?
![](https://uploads-us-west-2.insided.com/amplitude-en/attachment/1b3f4b43-4733-4fcb-9d91-c9aca2d3665a.png)
We also checked in Pathfinder and could see the following problem: Sometimes exposures seem to occur before the assignment event, is that an issue?
![](https://uploads-us-west-2.insided.com/amplitude-en/attachment/91907bd6-f24b-44d7-a404-bcf029fa28a0.png)
We included the Amplitude browser and experiment sdks via the npm modules @amplitude/experiment-js-client
and @amplitude/analytics-browser
We then initialize the experiment sdk like so:
private _experiment = Experiment.initializeWithAmplitudeAnalytics(
environment.amplitudeDeploymentKey,
{ fetchOnStart: true }
);
as well as the browser SDK:
amplitude.init(environment.amplitudeApiKey, { defaultTracking: true });
and here is the code that checks the variant with additional experiment.start() call just in case:
hasVariantValue(
experimentFlag: string,
variantValue: string
): Promise<boolean> {
return new Promise((resolve, reject) => {
this.initExperiments().then(
() => {
const variant = this._experiment.variant(experimentFlag);
resolve(variant.value === variantValue);
},
(err) => {
reject(err);
}
);
});
}
initExperiments(): Promise<boolean> {
if (this._initialized) {
return Promise.resolve(true);
}
return new Promise((resolve, reject) => {
this._experiment.start().then(
() => {
this._initialized = true;
resolve(true);
},
(err) => {
reject(err);
}
);
});
}
and is then used like so:
const amplitude = AmplitudeService.getInstance();
amplitude
.hasVariantValue('alt-title-searchbox', 'treatment')
.then((active) => {
console.debug('lamplitude] split test active = ', active);
if (active) { /* split test active */ }
});
We do not set any additional device or user ids.