一、修改文件:../data/class/SC_MobileView.php
function init() { parent::init(); $this->_smarty->template_dir = MOBILE_TEMPLATE_REALDIR; $this->_smarty->compile_dir = MOBILE_COMPILE_REALDIR; $this->assignTemplatePath(DEVICE_TYPE_MOBILE); //20130414 谷歌分析代码 $GA_ACCOUNT = "MO-1234567-8"; //记得改为自己的。 $GA_PIXEL = "/ga.php"; $url = ""; $url .= $GA_PIXEL . "?"; $url .= "utmac=" . $GA_ACCOUNT; $url .= "&utmn=" . rand(0, 0x7fffffff); $referer = $_SERVER["HTTP_REFERER"]; $query = $_SERVER["QUERY_STRING"]; $path = $_SERVER["REQUEST_URI"]; if (empty($referer)) { $referer = "-"; } $url .= "&utmr=" . urlencode($referer); if (!empty($path)) { $url .= "&utmp=" . urlencode($path); } $url .= "&guid=ON"; $this->_smarty->assign('googleAnalyticsImageUrl', str_replace("&", "&", $url)); //20130414 谷歌分析代码 END }
二、在footer.tpl中插入统计的图片
<img id="ga" src="<!--{$googleAnalyticsImageUrl}-->" />
三、修改文件../data/class/SC_MobileImage.php使图片能正常显示
//$pattern = '/<img\s+[^<>]*src=[\'"]?([^>"\'\s]+)[\'"]?[^>]*>/i'; //将上行修改为下面一行 $pattern = '/<img\s+[^<>(id=\'ga\')]*src=[\'"]?([^>"\'\s]+)[\'"]?\s*\/?/i'; //20130414谷歌分析
四、记得将ga.php上传到根目录下。