Get month over month email statistics

Occasional Contributor

Hi,

 

I am working on creating a marketing overview dashboard for my company.  We would like to see month over month email statistics.  Currently the only way to get that data is to manually export the emails on the "Marketing->Email" tab and select each month in the fixed time frame.  I am looking for an api that will allow me to get the same data that is available via that report but in an automated fashion.  


I wrote a script that warehoused every single email event in our hubspot instance (api endpoint: email/public/v1/events) which will work but the number of records is too big for my MySql database.  Any recommendations here would be great! I would think month over month email metrics would be a common request. 

 

Thank you,


Nick

Reply
0 Upvotes
4 Replies 4
HubSpot Moderator

Hi @nickmarshallmpg,

 

I think you should be able to do this using our Marketing Email API, which you can find documentation for here: https://developers.hubspot.com/docs/methods/lists/marketing-email-overview. You can filter the request in the request URL. So if you wanted to pull emails sent within a certain time range, you could use the endpoint documented here: https://developers.hubspot.com/docs/methods/cms_email/get-all-marketing-emails. Your request could look something like: marketing-emails/v1/emails?hapikey=XXXX&publish_date__gte=1556668800000&publish_date__lt=1559347200000 . And then using the IDs returned in the response, you can get the stats for an individual email through the endpoint documented here: https://developers.hubspot.com/docs/methods/cms_email/get-the-statistics-for-a-marketing-email. So far as I can tell, everything that's included in the report from the Email dashboard can also be found through these Marketing Email endpoints.

 

Let me know if that will help accomplish what you're looking for or if you have any questions here.

Leland Scanlan

HubSpot Developer Support
Reply
0 Upvotes
Regular Contributor

Hi @lscanlan,

 

I think that he ask about aggregation, so I'm join in Smiley Happy

 

I want to get marketing email statistics grouped by day.

(you have this option in Analytics API)

As I understand from the documentation https://developers.hubspot.com/docs/methods/cms_email/get-all-marketing-email-statistics

the endpiont retrieves only lifetime stats.

 

But in the Marketing dashboard I can choose from multiple date range options - so the daily data is somewere...

2019-09-24 15_23_32-Reports dashboard.png

Can you guid me how to retrieve daily statistics?

 

Reply
0 Upvotes
Highlighted
Occasional Contributor

What I ended up doing was grabbing all email events.  Here's the url: 

http://api.hubapi.com/email/public/v1/events

 

This will retrieve every single event which means that you will need a very big database to store it (make sure to index).  These event come with date stamps so I am using that field with Tableau to make month charts for email activity.  Let me know if  you have questions on how to break this out. Not ideal as an endpoint that had the aggregated monthly values would be much more efficient but it is working for now. 

 

Regular Contributor

Thanks. 

That what we do now...

 

But I hope that HubSpot will provied simple solution 

Reply
0 Upvotes