List Blog Post analytics by Blog

SOLVE
Regular Contributor

Hi all

I'm trying to use the API to get the CTA click rate data for all blog posts in a particular blog of ours.

Using the analytics API documentation I've managed to get a list of ALL blog posts sorted by entrances and limited to 100 results.

https://api.hubapi.com/analytics/v2/reports/blog-posts/total?&start=20190101&end=20190228&sort=entra...

The issue is, one of our HubSpot Hosted blogs is really old and it fills my results with blog posts that I don't want data for - using up way too many operations in Integromat.

The API documentation says:

"A blog ID can be specified to get data for all content related to a specific blog. The content_type must be blog-posts or listing-pages, see the examples for details."

However, in each of the examples they give, the blog ID option is always part of a sources report:

analytics/v2/reports/:content_type/content-group/:blog_id/sources/:time_period

I've managed to get the sources report, but that's not much help. I need the visit and CTA clicks for each blog post.

I tried putting the blog ID into my URL:

https://api.hubapi.com/analytics/v2/reports/blog-posts/content-group/1323969639/total?&start=20190101&end=20190228&sort=entrances&limit=100

But this just returns a 404.

Does anybody know how to add a filter so that I only get data for the blog I need?

Reply
0 Upvotes
2 Accepted solutions

Accepted Solutions
HubSpot Moderator

Hi, @LollipopRob.

 

Thanks for your patience. I appreciate the added clarification.

 

Unfortunately, the Analytics API does not allow for such filtering at this time.  I referenced our internal API catalog and confirmed that if you pass a blog's content-group ID in a request, it must be followed by /sources/.

 

While you currently can't exclude Social Media Blog posts from the request, there may be other ways to conserve operations.

 

Are you referencing this endoint for every blog post returned from /analytics/v2/reports/blog-posts/total?

 

If so, could you periodically update a table with all Fire & Security blog post IDs from this endpoint (using the content_group_id=1323969639 parameter) and use that to filter your results?

 

All this said, I definitely see the value in filtering this endpoint's non-sources results by blog, however. The team plans to release more flexible analytics endpoints in the future, but would you also mind posting a feature request describing your use case and pain here on the Ideas Forum? (I looked for similar existing ideas but found none.) Upvotes and comments help the product teams prioritize ideas which have the greatest potential impact on users, so I'll be happy to upvote if you share a link below.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Regular Contributor

Thanks Isaac, 

Here's the idea on the Ideas Forum: https://community.hubspot.com/t5/HubSpot-Ideas/Analytics-API-Get-Blog-Post-Data-by-Blog/idi-p/284517...

I think periodically updating a table with the newest blog ids is a great idea. If I store the latest visit data, CTA CTR data and sources data for each blog post, I will be able to use fewer operations when creating further automations regarding the Inbound blog in the future. 

I'm fairly new to all of this so do I really appreciate the help

Thanks again

5 Replies 5
HubSpot Moderator

Hi, @LollipopRob.

 

It sounds like you're trying to pull the ViewsCTA Views, and CTA clicks metrics visible in the Website Analytics tool from this Analytics API endpoint. Is that correct?

 

At this time, the public Analytics API endpoints are limited to reflecting the sources report, so they do not return CTA clicks like the report above. (Though I am seeing rawViews and ctaViews in our example JSON.)

 

That said, I was able to retrieve the analytics data for blog post 4011974019 by using the following request URL (using the blog post ID as as a page ID):

 

https://api.hubspot.com/analytics/v2/reports/blog-posts/4011974019/sources/total?start=20190101&end=20190228

Are you able to get results using that convention?

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Highlighted
Regular Contributor

Thanks for the reply Isaac

That URL does give some good data, I'm definitely going to use that.

However what I'm trying to achieve is getting the Blog Post analytics data from this URL:

https://api.hubapi.com/analytics/v2/reports/blog-posts/total?&start=20190101&end=20190228&sort=entra...

but just for blog posts in our Fire & Security Blog.

Currently that URL returns the analytics data for each individual blogs post in our Social Media Blog and our Fire & Security Blog - but the data doesn't tell me which Blog the blog post is part of.

This means I then have to do another check using the blog post IDs (https://api.hubapi.com/content/api/v2/blog-posts/BLOGPOSTID) to see whether each individual blog post is in the Social Media Blog or the Fire & Security Blog

As there are hundreds of blog posts in our Social Media Blog, it's using up too many of our operations in Integromat to do this, so I wanted to cut out the Social Media Blog from the initial request.

Do you know if that's possible?

Reply
0 Upvotes
HubSpot Moderator

Hi, @LollipopRob.

 

Thanks for your patience. I appreciate the added clarification.

 

Unfortunately, the Analytics API does not allow for such filtering at this time.  I referenced our internal API catalog and confirmed that if you pass a blog's content-group ID in a request, it must be followed by /sources/.

 

While you currently can't exclude Social Media Blog posts from the request, there may be other ways to conserve operations.

 

Are you referencing this endoint for every blog post returned from /analytics/v2/reports/blog-posts/total?

 

If so, could you periodically update a table with all Fire & Security blog post IDs from this endpoint (using the content_group_id=1323969639 parameter) and use that to filter your results?

 

All this said, I definitely see the value in filtering this endpoint's non-sources results by blog, however. The team plans to release more flexible analytics endpoints in the future, but would you also mind posting a feature request describing your use case and pain here on the Ideas Forum? (I looked for similar existing ideas but found none.) Upvotes and comments help the product teams prioritize ideas which have the greatest potential impact on users, so I'll be happy to upvote if you share a link below.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Regular Contributor

Thanks Isaac, 

Here's the idea on the Ideas Forum: https://community.hubspot.com/t5/HubSpot-Ideas/Analytics-API-Get-Blog-Post-Data-by-Blog/idi-p/284517...

I think periodically updating a table with the newest blog ids is a great idea. If I store the latest visit data, CTA CTR data and sources data for each blog post, I will be able to use fewer operations when creating further automations regarding the Inbound blog in the future. 

I'm fairly new to all of this so do I really appreciate the help

Thanks again

HubSpot Moderator

Upvoted! Thanks for sharing, @LollipopRob.

 

I'm glad I could help.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes