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

Key Description Value Type Required/Optional Constraints

Authorization

Access Token for the application

{{PARTNER_APP_TOKEN}}

String

Required

Should be a valid Partner App Access Token

start

start time of the query

{{START}}

Long

Optional

Epoch (If both start and end are not provided, default time corresponding to the last 30 days is populated in-code)

end

end time of the query

{{END}}

Long

Optional

Epoch (If both start and end are not provided, default time corresponding to the last 30 days is populated in-code)

granularity

granularity of template analytics

{{GRANULARITY}}

String

Optional

DAILY or AGGREGATED

Optional, if not provided, AGGREGATED is taken

metric_types

comma-separated string for metrics to fetch template analytics

{{METRIC_TYPES}}

String

Optional

SENT, DELIVERED, READ, CLICKED (all or some of the mentioned values)

Optional, if not provided, all the above-mentioned metrics are considered

template_ids

comma-separated string for gs template ids

{{TEMPLATE_IDS}}

String

Required

Currently supports only 1 template at a time

limit

no. of permitted entries in response per page; submitted during Meta call

{{LIMIT}}

Integer

Optional

Optional, if not provided, default is set to 30

Currently, the limit is supported to up to 30

Impacts response only if granularity is DAILY

appId

appId of the app to enable template analytics

{{APP_ID}}

String

Required

Should 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!