andeedee / gapi-google-analytics-php-interface

Automatically exported from code.google.com/p/gapi-google-analytics-php-interface
0 stars 0 forks source link

Does't accept no dimensions. #13

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. If dimensions are blank, it still tries to ga: them. You would want to send 
a req with no 
dimensions if you wanted aggregate stats.

Was easy enough  to patch, just pointing it out. 

Original issue reported on code.google.com by max.c...@gmail.com on 7 Aug 2009 at 4:43

Attachments:

GoogleCodeExporter commented 9 years ago
I had the exact same problem... thanks a lot!

Original comment by rafael.f...@gmail.com on 11 Mar 2010 at 6:28

GoogleCodeExporter commented 9 years ago
Agreed.  It's perfectly valid to omit dimensions for aggregate values.  I 
patched it by changing the block at 129 to this:

if( !empty($dimensions) ) {
    $parameters['dimensions'] = 'ga:'.$dimensions;
} else {
    $parameters['dimensions'] = '';
}

The problem is that the function doesn't check to see if the string is empty, 
so it always prepends 'ga:' to a non-array dimension.

Original comment by clavi...@gmail.com on 8 Jan 2011 at 11:16

GoogleCodeExporter commented 9 years ago
Here's an example if you want to test it out:

$ga->requestReportData(1234567890, null, array('bounces', 'entrances', 'exits', 
'newVisits', 'pageviews', 'timeOnPage', 'timeOnSite', 'visitors', 'visits'), 
null, null, $start_date, $end_date);

Original comment by clavi...@gmail.com on 8 Jan 2011 at 11:17

GoogleCodeExporter commented 9 years ago
for those who are new to PHP, the block starting at line 117 and ends at around 
line 129 should be deleted and replaced with:

    if(is_array($dimensions))
    {
      $dimensions_string = '';
      foreach($dimensions as $dimesion)
      {
        $dimensions_string .= ',ga:' . $dimesion;
      }
      $parameters['dimensions'] = substr($dimensions_string,1);
    }
    else 
    {
        if($dimensions != '')
        {
            $parameters['dimensions'] = 'ga:'.$dimensions;
        }
        else
        {
            $parameters['dimensions'] = '';
        }
    }

Original comment by maartenb...@gmail.com on 5 May 2011 at 11:10

GoogleCodeExporter commented 9 years ago
Thanks for this!

Original comment by i...@cre8websolutions.be on 15 Jun 2012 at 1:34