APIs & Integrations

brie
Member

Analytics API - Get data for HubSpot Content - page_id Required, how to get a list of valid IDs?

Hi There!

With the Hosted Content Documentation I see that the 'page_id' is a required field.

Is there a way to get a list of 'page_id' values that can be used with subsequent calls?

Is it in the List Pages Endpoint?

If so, is the 'analytics_page_id' from List Pages used in the 'page_id' field in the Analytics Endpoint?

Thanks so much!

0 Upvotes
3 Replies 3
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Analytics API - Get data for HubSpot Content - page_id Required, how to get a list of valid IDs?

Hi @brie,

You're correct on both fronts; you can get the page_id from the breakdown returned from the 'general' report from the Analytics API, and you can get them from the Pages API (see below). The same is true for blog posts. It's generally easier to obtain them from the more 'general' request to the Analytics API, since you know in advance that there exists data within your time frame for that piece of content.

0 Upvotes
brie
Member

Analytics API - Get data for HubSpot Content - page_id Required, how to get a list of valid IDs?

Hi There - wanted to check in on this.

Can anyone provide some guidance?

Thank you in advance!

0 Upvotes
brie
Member

Analytics API - Get data for HubSpot Content - page_id Required, how to get a list of valid IDs?

In further reviewing the Docs, perhaps these 'page_id' values are what's returned in the 'breakdown' response to the following request?

  • GET analytics/v2/reports/:content_type/:time_period

Then we would need to make individual requests for each value returned in 'breakdown' to

  • GET analytics/v2/reports/:content_type/:page_id/sources/:time_period

While for the blog posts, we would do something similar, recording the 'breakdown' field in the responses to

  • GET analytics/v2/reports/blog-posts/:time_period
  • GET analytics/v2/reports/listing-pages/:time_period

then input the response value for 'breakdown' into the 'page_id' field below:

  • GET analytics/v2/reports/blog-posts/:page_id/sources/:time_period
  • GET analytics/v2/reports/listing-pages/:page_id/sources/:time_period

Is this correct?

0 Upvotes