我使用此https://github.com/ins0/google-measurement-php-client库来跟踪发票,但我无法使Source / Medium工作。它向我显示,当我登录谷歌时,一切都来自(直接)/(无)。它不应该。
我的代码是这样的,以便解析cookie数据:
$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');
}
如果设置了AdwordsID,我会手动设置广告系列来源和媒介。在查询帖子中,我没有收到任何错误,交易项目显示在Google Analytics中,但广告系列来源和媒介仍然是(直接)/(无)。