我正在做我所有的谷歌分析服务器端,但 GA 只跟踪直接或推荐,我不知道如何跟踪有机。这是一段直接或推荐的代码:
//Campaign is used for the referrals
//If not in session and there is a referrer, create campaign from referrer
//and add it to the tracker and to session.
if (!isset($_SESSION['campaign'])) {
if (isset($_SERVER['HTTP_REFERER']) &&
strpos($_SERVER['HTTP_REFERER'], parse_url($this->config['url']['base'], PHP_URL_HOST)) === FALSE) {
$campaign = GoogleAnalytics\Campaign::createFromReferrer($_SERVER['HTTP_REFERER']);
$this->tracker->setCampaign($campaign);
$_SESSION['campaign'] = serialize($campaign);
}
} else {
//If already in session, add it to the tracker
$this->tracker->setCampaign(unserialize($_SESSION['campaign']));
}
以上基本分析了referer;如果来自其他来源,则创建推荐,如果不是,则不创建。如果有推荐,则将其存储在会话中。
现在,我将如何识别有机来源?我正在考虑制作一个可能的有机来源表,这是谷歌的做法吗?就像是:
protected $organic_sources = array('www.google.com', 'www.yahoo.com')
然后我会在创建活动之前检查那里的来源,如果在阵列中我会将其创建为有机活动。这是最佳解决方案吗?关于如何识别自然流量的任何想法?