我正在尝试进行服务器端 Google Analytics 跟踪并遇到了 php-ga。出于某种原因,这会引发错误: Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in /home/priedelc/public_html/refll/api_ga.php on line 85 - 其中 85 是使用 UnitedPrototype\谷歌分析;
有人给我提示吗?谢谢!
//load namespace
use UnitedPrototype\GoogleAnalytics;
//autoload import script
require_once 'autoload.php';
//initialze new tracker & session
$tracker = new GoogleAnalytics\Tracker('xxxx', 'xxxx');
$session = new GoogleAnalytics\Session();
//setup visitor
$visitor = new GoogleAnalytics\Visitor();
$visitor->setIpAddress($_SERVER['REMOTE_ADDRESS']);
$visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']);
//page
$page = new GoogleAnalytics\Page('/page-name');
$page->setTitle('Page Title');
//track pageview
$tracker->trackPageView($page,$session,$visitor);
//event
$event = new GoogleAnalytics\Event();
$event->setCategory('Category'); //string, required
$event->setAction('Action'); //string, required
$event->setLabel('Label'); //string, not required
$event->setValue(1); //integer, not required
$event->setNoninteraction('true');
//track event
$tracker->trackEvent($event,$session,$visitor);