Search code examples
google-analyticsgoogle-analytics-api

Google Analytics API query Active user


I want to query the number of Daily active user from Google analytics API, by the Event label.

In details: I have 2 event Categories, each contain 2 Event label. like this: (Category) -> (Action) -> (Label)

1. ui_category_A -> ui_action -> Click_button_A
2. ui_category_A -> ui_action -> Click_button_B
3. ui_category_B -> ui_action -> Click_button_A
4. ui_category_B -> ui_action -> Click_button_B

I want to query the Google analytics with API, to extract the number of daily active user, who have tracked the event with (1.) only.

How to do the query with parameters? Thanks!


Solution

  • To extract these data you should construct the API request with the library of your choice. Whichever you choose I will provide you with the parameters that will give you the results you want.

    • metrics: ga:users
    • dimensions: ga:eventCategory,ga:eventAction,ga:eventLabel
    • filters: ga:eventCategory==ui_category_A;ga:eventAction==ui_action;ga:eventLabel== Click_button_A
    • start_date: today
    • end_date: today

    If you just want the number of users you can skip the dimensions. Also be aware that the results will depend on the processing time of GA.

    If you want real-time results you can look into the beta of real-time reporting API