Skip to content
Advertisement

google analytics api v4 multiple metrics query

Ive been trying to get the metrics for all urls that contain a specific id in them. From this question: Adding ga:pagePath dimension to get page views for a particular URL using Google Analytics Reporting API v4 I saw the query approach and tried it instead of the object oriented version. In the query approach, the code works fantastic with the exception of it will only return the last metric sent (in this example it only returns unique page views since it is listed last for metrics). I need the values for all three returned without having to hit the api three separate times. Here is my code:

JavaScript

Any thoughts on how I would do this correctly?

Advertisement

Answer

Try the following function, just replace the ENTER_ID with you ID. This seems to fetch traffic for all pages though as well

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement