我在php中使用服务器端分析代码将Google Analytics与我的网站集成。
use UnitedPrototype\GoogleAnalytics;
// Initilize GA Tracker
$tracker = new GoogleAnalytics\Tracker('UA-XXXXXX', 'XXXXX.com');
// Assemble Visitor information
// (could also get unserialized from database)
$visitor = new GoogleAnalytics\Visitor();
$visitor->setIpAddress($_SERVER['REMOTE_ADDR']);
$visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']);
$visitor->setScreenResolution('1024x768');
// Assemble Session information
// (could also get unserialized from PHP session)
$session = new GoogleAnalytics\Session();
// Assemble Page information
$page = new GoogleAnalytics\Page($_SERVER['REQUEST_URI']);
$page->setTitle('My Page');
// Track page view
$tracker->trackPageview($page, $session, $visitor);
问题是,昨天它在网站上显示实时用户,但今天网站上显示的总访问量为零。 此服务器端实现是否存在问题。 ?
答案 0 :(得分:0)
最近谷歌推出了API - Google Real Time API,它提供了类似的功能。试试 - https://developers.google.com/analytics/devguides/reporting/realtime/v3/devguide