Amazon Kinesis (Cohort)
Amplitude Data's AWS Kinesis Cohort integration streams your cohort membership updates straight to a Kinesis stream.
Considerations
- This integration is only available for customers who have paid plans with Amplitude.
- You must enable this integration for each Amplitude project you want to use it in.
- You should understand Amplitude Activation and Behavioral Cohorts before setting up this integration.
- Amplitude supports all cohort update cadences (Daily, Hourly, Real Time).
- All existing Real Time Cohort Sync limits apply.
Prerequisites
Before you get started, create a Kinesis topic in your AWS account, and an IAM role that Amplitude uses to publish cohort updates to the stream.
Set up the integration
Kinesis setup
1. Create a Kinesis stream
Create a Kinesis stream in the AWS console.
2. Create an IAM role
Create an IAM role that gives Amplitude permission to write directly to your AWS Kinesis Stream.
- For Account ID, specify: 358203115967. This is Amplitude's AWS account used to export events.
- Finalize the role without assigning any policies.
- The Trust Relationships for the new role should look like this:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::358203115967:root"
},
"Action": "sts:AssumeRole"
}
]
}
3. Create an IAM policy
Create an IAM Policy to give Amplitude permission to write to your Kinesis Stream.
Select the Create Policy from JSON option and use the following template policy in the Policy Document field. Change
{account-id}to your account ID, and replace{region}and{stream-name}with the applicable values. Also replace{role-name}with the role you just created.json{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "kinesis:PutRecord", "kinesis:PutRecords", "iam:SimulatePrincipalPolicy" ], "Resource": [ "arn:aws:kinesis:{region}:{account-id}:stream/{stream-name}", "arn:aws:iam::{account-id}:role/{role-name}" ] } ] }Assign the new policy to the role.
- Open the role.
- Select the Attach Policies option, and select the new policy.
Make note of the role ARN, stream region, and stream name. You need these to set up the destination in Amplitude.
Amplitude setup
- In Amplitude Data, click Catalog and select the Destinations tab.
- In the Cohort section, click Kinesis Data Stream.
- Click Add another destination.
- Enter the Display Name for this destination. This name identifies the destination when syncing the cohort.
- Enter the stream name, AWS region, and role ARN you created.
- Save the destination.
Send a cohort
- In Amplitude, open the cohort you want to export.
- Click Sync, and choose Kinesis Data Stream.
- Select the destination you created.
- Select the sync frequency you need.
Payload
The payload sent to Kinesis is a JSON object. Example:
{
"cohort_name": "Test Cohort",
"cohort_id": "gs72ns",
"in_cohort": true,
"computed_time": "1685748245",
"message_id": "some-message-id:54",
"users": [{
"user_id": "user1@amplitude.com",
"user_properties": {
"city": "San Francisco",
"fav_animal": "Bat"
}
},
{
"user_id": "user2@amplitude.com",
"user_properties": {
"city": "Seattle",
"fav_animal": "Cat"
}
}]
}
| Field | Type | Description |
|---|---|---|
cohort_name | String | The name of the audience. |
cohort_id | String | The unique ID of the audience, also found in the URL when viewing it on Amplitude. |
in_cohort | Boolean | Indicates whether this batch of users is entering or exiting an audience. Each message has only one of either state, not both. |
compute_time | String | The Epoch timestamp when Amplitude re-computes the audience. Because Kinesis streaming can't enforce order on receipt, use this value to resume the order. Amplitude keeps it as a string rather than a number because some languages or platforms interpret JSON numbers as floats and lose precision. |
message_id | String | The unique id of each message. |
users | List | The users batch. Each user is represented as a JSON object containing user_id (String, the id of the user) and optionally user_properties (Map, with key as the property name and value as the property value). |
Was this helpful?