0

我在 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);

问题是,昨天它在网站上显示实时用户,但今天网站上显示的总访问量为零。这个服务器端实现是否有问题。?

4

1 回答 1

0

Recently Google has launched API - Google Real Time API which provide the similar functionality. try - https://developers.google.com/analytics/devguides/reporting/realtime/v3/devguide

于 2013-08-05T17:49:19.810 回答