Pageview data from API not matching Analytics GUI

512 views
Skip to first unread message

andy120

unread,
May 31, 2011, 11:45:29 AM5/31/11
to google-analytics-api - GA Data Export API
I am using a PHP script to retrieve data from the Google Analytics
API. I am retrieving the metric ga:pageviews by the dimension
ga:pagePath, sorted by pageviews. The data returned, though, does not
match the pageviews column in the "Top Content" report in the
Analytics GUI (though it is relatively close). Is there something
wrong with how I am retreiving the data or is the GUI looking at a
different metric other than ga:pageviews when it reports "Pageviews"?

This is the PHP class I am using: http://www.askaboutphp.com/63/google-analytics-api-class-for-php.html/,
but I also had the same problem when I ran the same report using GAPI
(http://code.google.com/p/gapi-google-analytics-php-interface/).

Any help anyone can provide would be much appreciated. Thanks!

-Andy

Nick

unread,
May 31, 2011, 8:59:51 PM5/31/11
to google-analytics...@googlegroups.com
What is the full query you are using?

And what exactly doesn't match, the pageviews for a particular page, or the totals?

-Nick 

andy120

unread,
Jun 6, 2011, 10:10:36 AM6/6/11
to google-analytics-api - GA Data Export API
$startDate = '2010-01-01';
$endDate = '2011-01-01';

$ga->setDateRange($startDate, $endDate);
$dimensions = 'ga:pagePath';
$metrics = 'ga:pageviews';
$filters = '';
$sortBy = '-ga:pageviews';
// get the report for date and country filtered by Australia,
showing pageviews and visits
$report = $ga->getReport(
array('dimensions'=>urlencode($dimensions),
'metrics'=>urlencode($metrics),
'filters'=>urlencode($filters),
'sort'=>$sortBy
)
);

The pageviews for the particular pages don't match. They end up being
in the same ballpark, but the larger the views, the larger the gap
between the script return and the GUI.

Thanks for your help,
Andy

andy120

unread,
Jun 6, 2011, 10:11:27 AM6/6/11
to google-analytics-api - GA Data Export API
Oops, the Australia comment is old (obviously these are not filtered
by country).

Nick

unread,
Jun 6, 2011, 1:03:06 PM6/6/11
to google-analytics...@googlegroups.com
Is your data getting sampled?

Also how does this data compare to when you create a custom report? (By default, the UI uses visits instead of pageviews)
-Nick

andy120

unread,
Jun 16, 2011, 3:09:03 PM6/16/11
to google-analytics-api - GA Data Export API
What do you mean by "sampled"?

Thanks,
Andy

andy120

unread,
Jun 28, 2011, 11:09:34 AM6/28/11
to google-analytics-api - GA Data Export API
Nick, it seems that I can use containsSampledData to find out whether
the data is sampled (which I'm starting to suspect is the situation).
Could you suggest an easy way to do this? I'm not quite sure how to
access that element in a query.

Thanks!
Andy

On Jun 6, 1:03 pm, Nick <api.ni...@google.com> wrote:

Jeetendra S.

unread,
Jun 28, 2011, 6:41:10 PM6/28/11
to google-analytics...@googlegroups.com
If you're using Java client library, you can call a method on DataFeed class to access this element. See http://code.google.com/p/gdata-java-client/source/browse/trunk/java/src/com/google/gdata/data/analytics/DataFeed.java?r=497#106

You can also use query explorer tool to make your query, which tells you if your data was sampled.


Jeetendra.

Reply all
Reply to author
Forward
0 new messages