Skip to main content

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?

 

 

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.


Any ideas?


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 




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"

}

}

}




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