I want a sample code for Google Analytics Data API (GA4) in PHP using orderBy and Filters

Viewed 623

I have gone through several git repositories to get the sample code using Filters and OrderBy using php-client-library for GA4 data analytics. Can you please help me with small sample code for using it ? I tried many ways but none are working.

My requirement I have was to sort the result by Dimention and also filters the top 10 pages with specific query string in the url.

This is the one I'm using for implementing : https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart-client-libraries#php_1

I also found that the samples link in php section opens a python samples :

enter image description here

  • Suresh
1 Answers
'orderBys' => [
    new OrderBy([
        'metric' => new MetricOrderBy(
            [
                'metric_name' => 'screenPageViews'
            ]
        ),
        'desc' => true
    ])
],
Related