I use this https://github.com/ins0/google-measurement-php-client library to track the invoices and I can't make Source / Medium to get working. It shows me that everything is from (direct) / (none) when I log in Google which it shouldn't.
My code is something like this in order to parse cookie data:
$params = explode('|', $aCookie['__utmz']);
$parts = explode('.', $params[0], 5);
array_unshift($params, $parts[4]);
$paramMap = array(
'utmcsr' => 'setCampaignSource',
'utmgclid' => 'setAdwordsID',
'utmdclid' => 'setDisplayAdsID',
'utmccn' => 'setCampaignName',
'utmcmd' => 'setCampaignMedium',
'utmcct' => 'setCampaignContent'
);
foreach ($params as $param) {
list($key, $val) = explode('=', $param);
if (isset($paramMap[$key]) === TRUE) {
$oObject->{$paramMap[$key]}($val);
}
}
$sAdwordsID = $oObject->getAdwordsID();
if (empty($sAdwordsID) === FALSE) {
$oObject->setCampaignName('google');
$oObject->setCampaignSource('google');
$oObject->setCampaignMedium('cpc');
}
I set Campaign Source and Medium manually if AdwordsID is set. On query post I get no errors, transaction item is showing up in Google Analytics however Campaign Source and Medium is still (direct) / (none).