A cohort is a static or dynamic set of users or groups defined in Amplitude. For experiment use cases, cohorts are particularly useful for advanced audience targeting. That said, cohorts aren't always the best solution for targeting, so understanding how cohort targeting works with local or remote evaluation is important.
When you target a cohort in a remote evaluation flag, the cohort is automatically synced to the Amplitude Experiment destination. For dynamic cohorts, this sync runs hourly by default. This means that dynamic cohorts targeted in remote evaluation aren't real-time. For example, if you target a cohort of users or groups who performed a Sign Up
event, users are targeted within an hour of performing the event.
Cohorts targeted for remote evaluation may have a propagation delay on the initial sync or large change, depending on the size of the difference. For example, the first sync of 10-million-user cohort is likely to take a lot more time than later syncs.
Use remote evaluation cohort targeting if:
Don't use remote evaluation cohort targeting if:
Local evaluation flags and experiment that are deployed to up-to-date server-side SDKs can also target cohorts. When you target a cohort in a local evaluation flag, the cohort is automatically synced to the Experiment Local Evaluation destination. For dynamic cohorts, this sync runs hourly by default. This means that dynamic cohorts targeted in local evaluation aren't real-time. For example, if you target a cohort of users who performed a Sign Up
event, users will be targeted within an hour of performing the event--not immediately after.
Server-side SDKs can target cohorts if configured to do so.
On initialization, configure the cohort sync configuration with the project API and secret key to enable local evaluation
cohort downloading and targeting.
SDK | Cohort Targeting | Version |
---|---|---|
Node.js | ✅ | 1.10.0+ |
Ruby | ✅ | 1.5.0+ |
JVM | ✅ | 1.4.0+ |
Go | ✅ | 1.7.0+ |
Python | ✅ | 1.4.0+ |
PHP | ❌ | N/A |
const experiment = Experiment.initializeLocal('DEPLOYMENT_KEY', {
// (Recommended) Enable local evaluation cohort targeting.
cohortSyncConfig: {
apiKey: 'API_KEY',
secretKey: 'SECRET_KEY'
}
});
// (1) Initialize the local evaluation client with a server deployment key.
LocalEvaluationClient experiment = Experiment.initializeLocal("<DEPLOYMENT_KEY>",
// (Recommended) Enable local evaluation cohort targeting.
LocalEvaluationConfig.builder()
.cohortSyncConfig(new CohortSyncConfig("<API_KEY>", "<SECRET_KEY>"))
.build());
client := local.Initialize("DEPLOYMENT_KEY", &local.Config{
// (Recommended) Enable local evaluation cohort targeting.
CohortSyncConfig: &local.CohortSyncConfig {
ApiKey: "API_KEY",
SecretKey: "SECRET_KEY"
}
})
experiment = Experiment.initialize_local("DEPLOYMENT_KEY", LocalEvaluationConfig(
# (Recommended) Enable local evaluation cohort targeting.
cohort_sync_config=CohortSyncConfig(api_key="API_KEY", secret_key="SECRET_KEY")
))
experiment = AmplitudeExperiment.initialize_local('DEPLOYMENT_KEY',
# (Recommended) Enable local evaluation cohort targeting.
AmplitudeExperiment::LocalEvaluationConfig.new(
cohort_sync_config: AmplitudeExperiment::CohortSyncConfig.new(
api_key: 'API_KEY',
secret_key: 'SECRET_KEY'
)
)
)
Troubleshooting cohort targeting can challenging due to the asynchronous nature of dynamic cohorts and cohort syncs in general. If you find that your experiment isn't targeting users who should be in the targeted cohort ...
fetch
/evaluate
is correct.August 12th, 2024
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2025 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.