GAPI kullanarak sayfa görüntüleme ve tekil ziyaretçi sayısı ile rapor oluşturma

0 Cevap php

I'm using GAPI to try and create simple reports from our Google Analytics data. My internal customer would like to see an overview with 2 fields per page: pageviews and unique visitors. I have the pageviews part working, but I cannot get the unique visitors part to work. This is my current code. The filter would be a parameter they can change, but is hardcoded for now:

require 'gapi.class.php';

$ga = new gapi(ga_email,ga_password);

$filter = 'pagepath =~ ^/home$';
$ga->requestReportData(ga_profile_id,
                        array('pagepath'),
                        array('pageviews'),
                       'pageviews',
                       $filter,
                       '2010-10-01',
                       '2010-10-31');

and then some code to show the results which is not really relevant here. As said, that works, but if I add 'visitors' to the metric like this:

$ga->requestReportData(ga_profile_id,
                       array('pagepath'),
                       array('pageviews','visitors'),
                       '-pageviews',
                       $filter,
                      '2010-10-01',
                      '2010-10-31');

Sonra bu hatayı alıyorum:

PHP Fatal error:  Uncaught exception 'Exception' with message 'GAPI: Failed to request report data. Error: "Illegal combination of dimensions and metrics"' in gapi.class.php:218

Stack trace:
#0example.filter.php(24): gapi->requestReportData('30296235', Array, Array, '-pageviews', 'pagepath =~ ^/h...', '2010-10-01', '2010-10-31')
#1 {main}
thrown in gapi.class.php on line 218

0 Cevap