Skip to main content
Solved

Unique Opens By Day From Metrics Agg API


Forum|alt.badge.img+1

I’m currently looping through days and grabbing the number of opens by flow for each day.  Below is my JSON:

 

'data': {
                "type": "metric-aggregate",
                "attributes": {
                    "metric_id": ID,
                    "measurements": [count],
                    "interval": "day",
                    "page_size": 500,
                    "by": ["$flow"],
                    "filter": f"and(greater-or-equal(datetime,{dt}T00:00-00:00),less-than(datetime,{dt}T23:59:59-00:00))",
                    "timezone": "UTC"
                },
            },
        }

 

This is fine, but I realized it doesn’t match the “Unique Opens” metric in the console.  How could I alter my logic above to get unique opens (or rather the first open for a given mailing)?  If I were to change measurements to “Unique” would I run into issues where an open could occur in different days and thus count on both days despite being the same mailer?

 

 

Best answer by Brian Turcotte

Hi @bweidfc!

Our API team is currently working on something to make it easier to match the dashboards in Klaviyo, and I will update the thread when that is released!

Best,

Brian 

View original
Did this topic or the replies in the thread help you find an answer to your question?

5 replies

Forum|alt.badge.img+1
  • Author
  • Contributor II
  • 3 replies
  • January 19, 2024

To be specific hear Customer A opens Campaign Y on 1/5/2024, and then opens Campaign Y again on 1/7/2024, would the JSON above count both of these or would it only count the first one?

My desired behavior is to only count the first which I assume aligns with the behavior of how unique opens is defined in the dashboard.  WHat’s most important is matching the dashboard’s version of unique opens while also being able to pull data by day.


Forum|alt.badge.img+1
  • Author
  • Contributor II
  • 3 replies
  • January 22, 2024

Any ideas?


Brian Turcotte
Forum|alt.badge.img+37
  • Klaviyo Alum
  • 1393 replies
  • Answer
  • January 23, 2024

Hi @bweidfc!

Our API team is currently working on something to make it easier to match the dashboards in Klaviyo, and I will update the thread when that is released!

Best,

Brian 


Forum|alt.badge.img
  • Contributor I
  • 1 reply
  • January 23, 2024



I was just digging into this, this morning and found querying by $message_send_cohort matches in-platform unique opens using the latest python SDK!

For December 2023 I return 128 via metric aggregates which matches the 128 I see in platform for the same message id

I have only tested this on a monthly interval so far but hope it helps.

references that lead me to this:
 

Mentions data exported from the platform uses send cohort:

 
$message_send_cohort is listed as a supported attribute here:

https://developers.klaviyo.com/en/docs/supported_metrics_and_attributes


example:

{"data": {

"type": "metric-aggregate",

"attributes": {

"measurements": ‘unique’,

"by": ‘$message_send_cohort’,

"filter": [

f"greater-or-equal(datetime,{start_date}T00:00:00)",

f"less-than(datetime,{end_date}T00:00:00)",

"equals($message,\"Wit9UX\")"

],

"metric_id": ‘your_opened_email_metric_id’,

"interval": "month",

"timezone": "US/Eastern"

}

}

}


cnorthcutt wrote:



I was just digging into this, this morning and found querying by $message_send_cohort matches in-platform unique opens using the latest python SDK!

For December 2023 I return 128 via metric aggregates which matches the 128 I see in platform for the same message id

I have only tested this on a monthly interval so far but hope it helps.

references that lead me to this:
 

Mentions data exported from the platform uses send cohort:

 
$message_send_cohort is listed as a supported attribute here:

https://developers.klaviyo.com/en/docs/supported_metrics_and_attributes


example:

{"data": {

"type": "metric-aggregate",

"attributes": {

"measurements": ‘unique’,

"by": ‘$message_send_cohort’,

"filter": [

f"greater-or-equal(datetime,{start_date}T00:00:00)",

f"less-than(datetime,{end_date}T00:00:00)",

"equals($message,\"Wit9UX\")"

],

"metric_id": ‘your_opened_email_metric_id’,

"interval": "month",

"timezone": "US/Eastern"

}

}

}

Thank you for your answer