Search code examples
google-analyticsgoogle-apigoogle-analytics-api

How to get the data from Google Analytics API up to sepcific hour


I'd like to get the data from Google Analytics with filter: hour below 15.

I've tried both the API and Query explorer and I'm getting some errors each time.

Below is my query:

Screen shot from the query explorer

Is there a way to make that work, please?


Solution

  • ga:hour is a dimension not a metric so it is a string (not a number).

    You can use regex like this:

    ga:hour=~(00|01|02|03|04|05|06|07|08|09|10|11|12|13|14)
    

    The regex can be optimized however the concept is the one described.