Search code examples
pythonchartsgoogle-analyticsgoogle-analytics-apigoogle-reporting-api

How to implement "Hourly, Day, Week, Month" functionality via Google Analytics Reporting API?


I need to replicate some of the functionality of google analytics in my web application via Reporting API. I know how to use it. The one I can figure out how to implement "Hourly, Day, Week, Month" functionality.

enter image description here

When I click any of those buttons, the selected date-frame remains the same, only the chart changes but how exactly it changes I can't understand because, again, selected date-frame remains the same. I want to get the explanation of how it works and how to implement it. I don't need the exact code, pseudo code is ok.


Solution

  • Clicking the buttons changes the period which each data point on the graph represents.

    So for the graph in your example, when daily is selected each data point represents a different date, while for month each point represents a different month.

    e.g. In GA if time period is 19th-25th April then selecting day will show 7 data points, 1 for each day, while selecting month will show 1 data point representing the whole week.

    However if month button pressed and the period is 16th March to 15th April, then there will be two data points, one representing 16th-31st March and the other representing 1st-15th April.