At a glance: Cohort API provides advertisers a programmatic way to get Cohort data. Use the API to integrate Cohort data into BI and marketing automation systems.
Cohort API
The Cohort API is used to get cohorted campaign performance data from the AppsFlyer platform. It is functionally equivalent to the Cohort dashboard.
To use Cohort and retention, you define the data that you want to view. You select users from an app and segment them by conversion time. Cohort metrics like revenue, ROI, and event conversion rates are available. Break the cohort down, for comparison purposes, into dimensions like campaign or media source. The result returns as a CSV or JSON file. You can use the results to uncover patterns or changes in performance over user or campaign life cycles.
See Cohort use cases.
To use Cohort API:
- Get the API token. An admin needs to retrieve the token.
- Give your developer the API token to be used in the authentication header.
- Give your developers the parameters to input when they make the API call, as described in the sections that follow. The parameters determine what the report focuses on, how it's organized, and provide a reporting timeframe.
- Tell your developer to follow their Cohort API instructions in the developer hub.
Cohort API parameters
Use the following parameters to get the necessary data.
Parameter name |
Description | Mandatory |
---|---|---|
bearer |
API token used in the API authentication header. |
Yes |
cohort _type |
Cohort attribution (conversion) type is one of the following:
|
Yes |
min_cohort_size |
Minimum cohort size is used to reduce the number of records returned by excluding cohorts having few users. This means that the "users" KPI has a value equal or greater to that specified.
|
No |
from |
Lower bound of the LTV attribution date range. The earliest date supported is 720 days before the current date.
|
Yes |
to |
Higher bound of the LTV attribution date range
|
Yes |
granularity |
Hourly granularity for the previous 72 hours by setting
"granularity": "hour",
"from": "2021-12-01 14:00:00", "to": "2021-12-03 11:00:00",
|
No |
partial_data |
To avoid data distortion and misinterpretation Cohort returns data of complete days. However, the data of partial days can be useful. The number of complete cohort days for a query is calculated as the difference between today's date and the to date.
Example: On May 10, the number of complete cohort days for users converting during April 1-30, is 10.
Note: Partial data is only allowed when the aggregation type is cumulative. |
No |
filters |
Filter the data and period days returned. Select filters from the filter dimensions list.
|
No |
groupings |
|
Yes |
kpis |
KPIs are the metrics used for gaining insights into the behavior of your app. Learn how to select and format KPIs | Yes |
preferred_currency | A parameter that sets the format of the KPIs returned. Learn how to format KPIs | No |
preferred_timezone | A parameter that sets the format of the KPIs returned. Learn how to format KPIs | No |
aggregation_type | A parameter that sets the format of the KPIs returned. Learn how to format KPIs | Yes |
per_user | A parameter that sets the format of the KPIs returned. Learn how to format KPIs | No |
Selecting and formatting KPIs
- The table lists the KPIs available and their associated functions. When you call a KPI, all its functions return.
- The following KPIs always return: users, ecpi, and cost
- Select one additional KPI per call.
- For each KPI requested, all functions are returned.
- Format: Strings in an array
- Example A:
"kpis": ["sessions"]
- Example B:
"kpis": ["event_name"]
- Example A:
Functions | ||||||
---|---|---|---|---|---|---|
Default/ Optional | KPI (Dimensions name) | Count | cvr (conversion rate) | Rate | Sum | Unique users |
Number | Percentage | Percentage | Number | Number | ||
Always | users | Y | - | - | - | - |
Always | ecpi | - | - | Y | - | - |
Always | cost | - | - | - | Y | - |
Optional | "event_name" (4) |
Y | Y | - | Y (3) | Y |
Optional | revenue | Y | - | - | Y | - |
Optional | roas | - | - | Y | - | - |
Optional | roi | - | - | Y | - | - |
Optional | sessions | Y | - | Y | - | Y(1) |
Optional | uninstalls (2) | Y | - | Y | - | - |
(1) Unique sessions returns when aggregation_type=on_day (2) Not available when cohort_type=unified (3) Sum means the total revenue generated by the event. In the report, this is denoted by (4) Note! Event names are case-sensitive |
Formatting KPI functions
The following parameters set the format of the KPIs returned.
Parameter |
Values | Mandatory |
---|---|---|
preferred_currency |
KPI revenue currency
|
No |
preferred_timezone |
Time zone of data ranges
|
No |
aggregation_type |
|
Yes |
per_user |
Divide the KPI function by the number of app users. Applies only to relevant KPIs.
|
No |
Group by and filter dimensions
Dimension name |
Dimension API value |
Groupings |
Filters |
---|---|---|---|
Ad |
af_ad |
Y |
Y |
Ad ID |
af_ad_id |
Y |
Y |
Campaign |
c |
Y |
Y |
Campaign ID |
af_c_id |
Y |
Y |
Channel |
af_channel |
Y |
Y |
Media Source |
pid |
Y |
Y |
Sub Param 1 |
af_sub1 |
Y |
Y |
Keywords |
af_keywords |
Y |
Y |
Agency |
af_prt |
Y |
Y |
Conversion Type (1) |
cohort_type |
Y |
Y |
Site ID |
site_id |
Y |
Y |
Revenue Type (2) |
revenue_type |
x |
Y |
Attributed Touch Type (3) |
attributed_touch_type |
Y |
Y |
Adset |
af_adset |
Y |
Y |
Adset ID |
af_adset_id |
Y |
Y |
Country |
geo |
Y |
Y |
Date (install/re-attribution/re-engagement date in the context of the cohort_type selected) |
date |
Y |
x |
Period |
period
|
x |
Y |
Notes: Dimension options: (1) Conversion Type:
(2) Revenue Type: click , impression , TV , pre-installed
|
Additional information
Using period filters
Period refers to the day post-attribution, where period 0 is the attribution day. For example, a user installs the app on January 1. This is the attribution day. A purchase made on period 0 means it was made on January 1. A purchase made on period 3 means it was made on January 4. Similarly, a user who installs on January 11, this is period 0. A purchase made on January 14 would be period 3.
If your report date range is January 1 to January 11 users who attributed (installed) during this period are included in the report. No other data is included.
- The value of the period can be one or more of the following 0-180. For example, 0, 1, 2, 30, 180.
- If no period is specified, the default values of 0, 1, 2, and so on to 30, 60, 90, and 180 return.
Example period filter
- This example contains the JSON query parameters, raw data, and resulting CSV file.
- The query filters period of 0, 1, and 2 and the KPI selected is revenue.
- The query specifies the aggregation type as "cumulative". Change to "on_day" if you want on-day data.
- As a result, the data returned contains:
- The measures of users, cost, and ecpi which always return
- Revenue measures consisting of sum and count for each period meaning periods 0, 1, and 2.
Query
{
"cohort_type": "user_acquisition",
"min_cohort_size": 1,
"preferred_timezone": false,
"from": "2019-12-01",
"to": "2020-01-01",
"filters": {
"period": [
0,
1,
2
]
},
"aggregation_type": "cumulative",
"per_user": false,
"groupings": [
"pid"
],
"kpis": [
"revenue"
]
}
Raw data
Results
Traits and limitations
Trait | Remarks |
---|---|
Ad network access |
No |
Agency access | No |
Agency transparency | Not supported. The media source of agency-driven traffic is always the agency and not the original media source. |
App-specific time zone | Yes |
App-specific currency | Yes |
Size limitations | None |
Rate limitation |
|
Organic data | Available |
Non-organic data | Available |
Cost data limitation |
|
Data freshness |
Data freshness depends on partial_data as follows:
|
Historical data | Daily cohort: 2 years |
Account user access | The authorization token is available to admin users in the dashboard |
Ad revenue |
For af_ad_revenue events, the unique users metric isn't available when the aggregation type is:
|
Weekly and monthly groupings |
Weekly and monthly dimension groupings aren't available with the Cohort API. Use the Cohort dashboard. |
Cohort API period |
|
Dates |
|
Reinstalls |
|
Cohort API for partners |
Access to the Cohort API for marketing partners is being deprecated as of September 15th, 2024. Marketing partners are encouraged to enable Data Locker to ensure continued access to customer data. |