APIs & Integrations

Todd7
Member

Get email stats for emails sent via Marketing Email API in range

I'm trying to programatically grab all email stats for emails that are sent in specific range(lets say last month) via Marketing Email API. Ideally I'd want to get same info I get via Marketing Email > Analyze > Overview, where if i filter emails by month I get all the emails that are sent during that month.

 

When using Marketing Email API I can't seem to filter the emails in such a way to only get those that are sent during that month, using create/publish range gets me those that are created in that month and total emails sent since then which is completely off from what I'd like to get.

6 Replies 6
WendyGoh
HubSpot Employee
HubSpot Employee

Get email stats for emails sent via Marketing Email API in range

Hi @Todd7,

 

I hope all is well with you 😄

 

When looking to filter emails that are sent during that month, you can look into using the filter type  `publish_date__gt`.

 

When I use the following parameter on the Get all marketing emails statistics endpoint:

marketing-emails/v1/emails/with-statistics?portalId={{portal_id}}&publish_date__gt=1567180800000

I'm able to see that I'm only getting back emails sent after 2019/08/31 which means I'm only getting back emails sent this month (September). Additionally, I use the https://currentmillis.com/ site to convert local time to milliseconds.

 

Hope this helps to clarify!

0 Upvotes
OOgbonna
Member

Get email stats for emails sent via Marketing Email API in range

Hi Wendy,

 

I wanted to know if this was resolved and how it was resolved as I am currently same issue. 

 

Thanks, 

Onyi

0 Upvotes
Todd7
Member

Get email stats for emails sent via Marketing Email API in range

Hi Wendy,

 

That's a similar query to what I've been using(I was using a range filter), I'm still getting wrong info even with your query. If I set the unix timestamp to yesterday, I'll get back 0 results but the dashboard reports 30~ emails with 300+ instances sent since yesterday. If I switch back to `publish_date__range` and use last month as a filter I'll get only 2 results(those that were initially published last mont) and it will show me total number of emails sent since then(everything up to today, not just those sent last month). Its acting as if I'm using the `created` filter instead.

 

 

0 Upvotes
WendyGoh
HubSpot Employee
HubSpot Employee

Get email stats for emails sent via Marketing Email API in range

Hi @Todd7,

 

Do you mind sharing with me the exact endpoint url with the parameters for the endpoint that you're getting the email statistics? As well as your portal ID? 

 

If it's more comfortable for you, you can send me these information via DM.

0 Upvotes
VDadasheva
Member

Get email stats for emails sent via Marketing Email API in range

Hi @WendyGoh I  have similar issue. There is my endpoint 

/emails/with-statistics?created__lt={utc_time_end_day}&created__gt={utc_date_start_day}

 if i use something like /emails/with-statistics?created__gt={1656417017652*-1}, or /emails/with-statistics?created__lt={1656417017652*+1} - i recieve correct array.

 

*1656417017652 - one of my email was send with this date

 

 

i tried to use 

 "filterGroups":[
{
"filters":[
{
"propertyName": "created",
"operator": "GTE",
"value": f"{1656417017652-2}"
},
{
"propertyName": "createdate",
"operator": "LTE",
"value": f"{1656417017652+2}"
}
]
}
],
}

but it doesn't work correct for me too.

How can i create request and get emails(with statistics) that will be between two dates?

0 Upvotes
VDadasheva
Member

Get email stats for emails sent via Marketing Email API in range

resolved. 

for me it works with params in url

example:

/emails/with-statistics?created__range={utc_date_start_day},{utc_time_end_day}

 utc_date_start_day, utc_time_end_day - should be converted to MILLISECONDS.

 

0 Upvotes