Get Template Analytics for a template

Use this API to get template analytics for a template

📘

Note

You will get the results in IST

Request Parameters

KeyDescriptionValueTypeRequired/OptionalConstraints
AuthorizationAccess Token for the application{{PARTNER_APP_TOKEN}}StringRequiredShould be a valid Partner App Access Token
startstart time of the query{{START}}LongOptionalEpoch (If both start and end are not provided, default time corresponding to the last 30 days is populated in-code)
endend time of the query{{END}}LongOptionalEpoch (If both start and end are not provided, default time corresponding to the last 30 days is populated in-code)
granularitygranularity of template analytics{{GRANULARITY}}StringOptionalDAILY or AGGREGATED

Optional, if not provided, AGGREGATED is taken
metric_typescomma-separated string for metrics to fetch template analytics{{METRIC_TYPES}}StringOptionalSENT, DELIVERED, READ, CLICKED (all or some of the mentioned values)

Optional, if not provided, all the above-mentioned metrics are considered
template_idscomma-separated string for gs template ids{{TEMPLATE_IDS}}StringRequiredCurrently supports only 1 template at a time
limitno. of permitted entries in response per page; submitted during Meta call{{LIMIT}}IntegerOptionalOptional, if not provided, default is set to 30

Currently, the limit is supported to up to 30

Impacts response only if granularity is DAILY
appIdappId of the app to enable template analytics{{APP_ID}}StringRequiredShould be a valid appId

Sample Request

curl --location --request GET '{{BASE_URL}}/partner/app/{{APP_ID}}/template/analytics?start=1711935412&end=1712021812&granularity=DAILY&metric_types=SENT,DELIVERED,READ,CLICKED&template_ids={{TEMPLATE_ID}}&limit=30' \
--header 'Authorization: {{PARTNER_APP_TOKEN}}'

Sample Response

{
    "status": "success",
    "template_analytics": [
        {
            "clicked": [
                {
                    "button_content": "imgurl1",
                    "count": 8,
                    "type": "url_button"
                },
                {
                    "button_content": "imgurl2",
                    "count": 6,
                    "type": "url_button"
                }
            ],
            "delivered": 2,
            "end": 1706572800,
            "read": 1,
            "sent": 2,
            "start": 1706400000,
            "template_id": "2c679517-6450-4556-abff-a64d1355ee7e"
        }
    ]
}

Status Codes

Status CodeResponseComments
Success
200{ "status": "success", "template_analytics": \[ { "clicked": [ { "button_content": "imgurl1", "count": 8, "type": "url_button" }, { "button_content": "imgurl2", "count": 6, "type": "url_button" } ], "delivered": 2, "end": 1706572800, "read": 1, "sent": 2, "start": 1706400000, "template_id": "2c679517-6450-4556-abff-a64d1355ee7e" } ] }Successful response
200{ "status": "success", "template_analytics": \[] }When Meta’s API returns no data_points (this is found to occur when template has no buttons, or template is authentication type, and button clicks are disabled and we query for only CLICKED as metric type)
Error
401{ "status": "error", "message": "Unauthorised access to the resource. Please review request parameters and headers and retry" }Bad request
400{ "message": "Start time can't be older than 90 days", "status": "error" }
404{ "message": "Template Analytics settings for app f3bf7a6b-d694-412e-a5dd-6925c8bb2d15 does not exist", "status": "error" }
Language
Click Try It! to start a request and see the response here!