Eks27
Eks27

Reputation: 1

How to get unique users in a given period of time in Google Analytics through API?

How do I get unique users in a given period of time in Google Analytics through API? For example, I want to get unique users from 2022-10-01 to 2022-10-12. I know there's a feature called 30 Day Active Users in GA, but it is impossible to calculate only for the given period (12 days, not 30 days)

Upvotes: 0

Views: 428

Answers (1)

arun-dev
arun-dev

Reputation: 19

You can use dataRange attribute with metrics and dimensions to filter the specific date visitors

For example

 'json' => [
           'reportRequests' => [
                'viewId' => "viewId",
                'dateRanges' => [
                    "startDate" => "2022-10-01",
                    "endDate" => "2022-10-12"
                   ],
                'dimensions' => ['name' => 'ga:date'],
                'metrics' => ['expression' => 'ga:visitors'],
                ]
            ]

To find more about metrics and dimensions refer this https://ga-dev-tools.web.app/dimensions-metrics-explorer/

Upvotes: 1

Related Questions