Get campaign metrics
Returns a list of metrics for an individual campaign. The available parameters and response format depend on the version parameter that you use with this endpoint. We strongly recommend that you use version=2 with this endpoint:
Version 2 (Recommended):
- Uses
res,tz,start, andendparameters - Based on resolution and optionally, time zone, start and end times
- Provides maximum flexibility for time-based metrics
Version 1 (Deprecated):
- Uses
periodandstepsparameters - Based on steps (days, weeks, etc)
- Returns metrics from oldest to newest (i.e. the 0-index for any result is the oldest step/period)
- You cannot request fewer than 2 steps of any period (2 hours, 2 days, 2 weeks, or 2 months)
- For instance,
?period=days&steps=1means two days - the 48 hours before the API request was made ?period=days&steps=0returns the same as the maximum of the period -?period=days&steps=45
- Type: integercampaign
_id requiredThe ID of the campaign that you want to trigger or return information about.
- Type: stringenumversionrequired
The version of the metrics API to use.
values- 1
- 2
- Type: stringenumtype
The type of item you want to return metrics for. When empty, the response contains metrics for all possible types.
values- email
- webhook
- twilio
- whatsapp
- slack
- push
- in
_app - live
_notification
- Type: stringenumres
Version 2 only. Determines increment for metrics—hourly, daily, weekly, or monthly.
values- hours
- hourly
- days
- daily
- weeks
- weekly
- months
- monthly
- Type: stringtz
Version 2 only. The time zone for the metrics you are requesting. If you do not provide a time zone, we use EST. You must use the region format.
- Type: integerFormat: unix timestampstart
Version 2 only. The unix timestamp for the beginning of your metrics.
- Type: integerFormat: unix timestampend
Version 2 only. The unix timestamp for the end of your metrics. Limited to 10 years from the
startparameter. - Type: stringenumperiod
Version 1 only. The unit of time for your report.
values- hours
- days
- weeks
- months
- Type: integersteps
Version 1 only. The number of periods you want to return. Defaults to the maximum available, or
12if the period is inmonths. Maximums are 24 hours, 45 days, 12 weeks, or 120 months.
- application/json
- 400
The
campaignIDoractionIDis invalid. - 404
The campaign and/or action do not exist.
- 429
Your request is over the 10-per-second limit.
curl 'https://api.customer.io/v1/campaigns/3/metrics?version=1&type=email&res=hours&tz=America%2FNew_York&start=1652718066&end=1&period=days&steps=1' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN'
{
"metric": {
"series": {
"2xx": [
1
],
"3xx": [
1
],
"4xx": [
1
],
"5xx": [
1
],
"attempted": [
1
],
"bounced": [
1
],
"clicked": [
1
],
"human_clicked": [
1
],
"prefetch_clicked": [
1
],
"converted": [
1
],
"created": [
1
],
"deferred": [
1
],
"delivered": [
1
],
"drafted": [
1
],
"failed": [
1
],
"opened": [
1
],
"human_opened": [
1
],
"prefetch_opened": [
1
],
"sent": [
1
],
"spammed": [
1
],
"suppressed": [
1
],
"undeliverable": [
1
],
"topic_unsubscribed": [
1
],
"unsubscribed": [
1
]
}
}
}Returns campaign metrics by series based on the version and parameters of the request.