php - Pulling Google Analytics Multi Channel Funnel data via API -
i trying pull multi-channel funnel reports google analytics api , getting following error:
invalid value 'mcf:source'. values must match following regular expression: '(ga:.+)?'
here code using, works fine when dimensions & metrics ga:... family, reason won't let me pull mcf: reports.
$analytics = new google_service_analytics($client); $analytics_id = 'ga:xxxxxxxx'; $lastweek = date('y-m-d', strtotime('-26 day', time())); $today = date('y-m-d', strtotime('-26 day', time())); try { $optparams = array(); $optparams['dimensions'] = "mcf:source"; #$optparams['sort'] = ""; $optparams['max-results'] = "10000"; $metrics = 'mcf:totalconversions'; $results = $analytics->data_ga->get($analytics_id, $lastweek, $today,$metrics,$optparams); $rows = $results->getrows(); foreach ($results->columnheaders $header) { $headername = ucwords(preg_replace('/(\w+)([a-z])/u', '\\1 \\2', str_replace('ga:', '', $header->name))); printf('%s', $headername); print ','; } print "\n"; foreach ($results->rows $row) { foreach ($row $cell) { printf('%s', $cell); print ','; } print "\n"; } }
from top of head i'd it's because using $analytics->data_ga->get()
instead of $analytics->data_mcf->get()
(multichannel data has it's own api).
Comments
Post a Comment