Skip to main content
Contributor I
May 10, 2023
Solved

Is there an API endpoint to fetch campaign stats?

  • May 10, 2023
  • 2 replies
  • 626 views

We are sending daily email campaigns to our subscribers. We use Tableau for reporting. I need to fetch campaign performance stats (emails sent, opens count, clicks count, unsubs count, etc.) using the API. 

I see that I can query the API and fetch list of campaigns, etc. but I don’t see an API endpoint to fetch stats. Am I missing something? What the best way to get stats from Klaviyo?

    This topic has been closed for replies.
    Best answer by David To

    Hello@red3i,

    Welcome to the Klaviyo Community!

    This is something supported under our query metric aggregate endpoint. I would suggest taking a read through our (New) Using the Query Metric Aggregates Endpoint Developer Guide which covers this and offer some example calls. 

    For example, to query unique opens for all sent messages you can use:

    {  
    "data": {
    "type": "metric-aggregate",
    "attributes": {
    "measurements": [
    "unique"
    ],
    "filter": [
    "greater-or-equal(datetime,2022-01-01)",
    "less-than(datetime,2022-12-31)"
    ],
    "by": ["$message"],
    "interval": "month",
    "timezone": "US/Eastern",
    "metric_id": "QhyxVR"
    }
    }
    }

    For unique opens for a specific message, you can use:

    {  
    "data": {
    "type": "metric-aggregate",
    "attributes": {
    "measurements": [
    "unique"
    ],
    "filter": [
    "greater-or-equal(datetime,2022-01-01)",
    "less-than(datetime,2022-12-31)",
    "equals($message,\"01GAQWA31SZKABEZJNXDBGW2F1\")"
    ],
    "interval": "month",
    "timezone": "US/Eastern",
    "metric_id": "QhyxVR"
    }
    }
    }

     I hope this helps!

    David

    2 replies

    David To
    Klaviyo Employee
    David ToAnswer
    Klaviyo Employee
    May 10, 2023

    Hello@red3i,

    Welcome to the Klaviyo Community!

    This is something supported under our query metric aggregate endpoint. I would suggest taking a read through our (New) Using the Query Metric Aggregates Endpoint Developer Guide which covers this and offer some example calls. 

    For example, to query unique opens for all sent messages you can use:

    {  
    "data": {
    "type": "metric-aggregate",
    "attributes": {
    "measurements": [
    "unique"
    ],
    "filter": [
    "greater-or-equal(datetime,2022-01-01)",
    "less-than(datetime,2022-12-31)"
    ],
    "by": ["$message"],
    "interval": "month",
    "timezone": "US/Eastern",
    "metric_id": "QhyxVR"
    }
    }
    }

    For unique opens for a specific message, you can use:

    {  
    "data": {
    "type": "metric-aggregate",
    "attributes": {
    "measurements": [
    "unique"
    ],
    "filter": [
    "greater-or-equal(datetime,2022-01-01)",
    "less-than(datetime,2022-12-31)",
    "equals($message,\"01GAQWA31SZKABEZJNXDBGW2F1\")"
    ],
    "interval": "month",
    "timezone": "US/Eastern",
    "metric_id": "QhyxVR"
    }
    }
    }

     I hope this helps!

    David

    red3iAuthor
    Contributor I
    May 11, 2023

    Thank you David. Appreciate your response!