google analytics api query a specific url

后端 未结 3 1169
慢半拍i
慢半拍i 2020-12-29 12:44

I am accessing the Google analytics API with PHP which works on my end but I\'d love to filter the results a bit further. Right now I am using:

$OBJresult =          


        
3条回答
  •  孤城傲影
    2020-12-29 13:10

    You need to use the filters string to say "if path includes /news" which can be done as follows:

    $OBJresult=$analytics->data_ga->get(
        'ga:'.$profilID,
        '2012-01-01',
        date("Y-m-d"),
        'ga:visits',
        array(
            'filters' => 'ga:pagePath=@/news',
            'dimensions' => 'ga:pagePath',
            'metrics' => 'ga:pageviews',
            'sort' => '-ga:pageviews',
            'max-results' => '25'));
    

    The answer supplied by Barmar will only find an exact match for the /news page.

提交回复
热议问题