hundreds-student-36571
08/29/2025, 4:13 PMexport const gbInstance = new GrowthBook({
apiHost: import.meta.env.VUE_APP_GROWTHBOOK_API_HOST,
clientKey: import.meta.env.VUE_APP_GROWTHBOOK_CLIENT_KEY,
enableDevMode: !isProduction(),
plugins: [autoAttributesPlugin()],
trackingCallback: (experiment, result) => {
$analytics.track({
event_type: 'Experiment Viewed',
event_properties: {
experimentId: experiment.key,
variationId: result.key
}
});
console.log(`key-${experiment.key} result-${result.key}`);
}
});
const initializeGrowthBook = async () => {
try {
if ($analytics) {
gbInstance.updateAttributes({
id: $analytics.amplitude.getUserId(),
deviceId: $analytics.amplitude.getDeviceId()
});
}
await gbInstance.init({ streaming: true });
gbFlags.initialize(gbInstance);
return gbInstance;
} catch (e) {
return null;
}
};
I’m implementing it like this, and in the plugins I specify autoAttributesPlugin(). That generates attributes for targeting (one of them is id).
When setting up an experiment in the admin panel, you can assign it based on anonymous_id or user_id. How is this id connected with user_id or anonymous_id? Or do I need to explicitly set user_id and anonymous_id when initializing?
If so, how should this be connected with Amplitude, since it has both user_id and device_id?