Open GoogleCodeExporter opened 9 years ago
I've been attempting similar things, though it's the dynamic filtering that I
wanted
to use instead of the goals.
So here's my hack to get things working - debugging welcome! (though it seems
to work
in the simple cases I've used it for so far, mostly traffic source segmentation
etc.)
Suggest this and the addition above be combined, QA'd and added to next release
of
GAPI?
Note: should probably add v2 to the HTTP header, not a param as I've done.
Note: used the processFilter function to duplicate functionality. Will this
cause any
issues?
######################################
Modify the requestReportData function to show as follows:
public function requestReportData($report_id, $dimensions, $metrics,
$sort_metric=null, $filter=null, $start_date=null, $end_date=null,
$start_index=1,
$max_results=100, $segments=null)
{
$parameters = array('ids'=>'ga:' . $report_id);
/* segmentation params
* adam marshall dec 2009
* specifiy either :
* $segments Integer id of segment to use
* $segments String dynamic segment e.g. 'medium==referral' [ use the same
form as filters, see example.filter.php ]
* **********************************/
if ($segments !== null)
{
if (!is_int($segments))
{
$parameters['segment'] = 'dynamic::'.$this-
>processFilter($segments);
}
else
{
$parameters['segment'] = 'gaid::'.$segments;
}
$parameters['v'] =2;
}
/* end segmentation params */
and then the function continues from the "if ($dimensions !== null)" line
onwards...
Original comment by logan...@googlemail.com
on 22 Dec 2009 at 4:18
logantod. You, sir, win, and I shall be replacing my slightly different
variation of segment implementation with
your cleaner one. Thank you.
Original comment by wraithof...@gmail.com
on 25 Jan 2010 at 1:55
Jason, your fix worked like a charm! It's made my flexible "show the clients
their GA
data in our extranet" project much schnazzier!
Original comment by g...@bacs.org
on 22 Feb 2010 at 9:36
Original issue reported on code.google.com by
jasonw...@gmail.com
on 16 Dec 2009 at 1:09