2

I'm using the code :

function get_indiv_visitors($site_id, $start_date, $end_date=NULL) {
        require 'config.php';
        $ga = new gapi($ga_email,$ga_password);
        $ga->requestReportData($site_id, array('pagePath'),array('Visitors'),         $sort_metric=null, $filter=null, $start_date, $end_date);
        $totalvisitors = $ga->getVisitors();
        return $totalvisitors;
} 

This code works, but returns a number that is greater than visits (which I cross references with the google analytics sites, so those numbers are definitely correct). It doesn't make sense that I should have more visitors than visits.

2 Answers2

1

It has to do with how GA tracks visits and visitors:

The visit is assigned to the first page but not subsequent pages, whereas unique visitors are assigned to each page

See Unique visitors, 0 visits and pages in web analytics

jk.
  • 14,365
  • 4
  • 43
  • 58
1

change the dimension to 'userDefinedValue'

function get_indiv_visitors($site_id, $start_date, $end_date=NULL) {
        require 'config.php';
        $ga = new gapi($ga_email,$ga_password);
        $ga->requestReportData($site_id, array('userDefinedValue'),array('Visitors'),            $sort_metric=null, $filter=null, $start_date, $end_date);
        $totalvisitors = $ga->getVisitors();
        return $totalvisitors;
}