我有一个已经使用的网站,但是它没有发送Ajax操作的页面视图(比如动态搜索引擎),我没有找到一个API来通过服务器发送它。
发布于 2014-07-22 08:19:43
对于您的任务,请查看Google Measurement Protocol https://developers.google.com/analytics/devguides/collection/protocol/v1/?hl=de
现在我要指出我的Github项目--也许它对您的任务是有用的。
https://github.com/ins0/google-measurement-php-client
它是一个PHP客户端库,可以从服务器端与Google通信.
// autoloader
require_once( dirname(__FILE__) . '/../src/Racecore/GATracking/Autoloader.php');
Racecore\GATracking\Autoloader::register(dirname(__FILE__).'/../src/');
// init tracking
$tracking = new \Racecore\GATracking\GATracking('UA-XXXXXXXX-X',false);
// optional when not setting the client id by constructor
$tracking->setAccountID('UA-XXXXXXXX-X');
/**
* Page Tacking
*/
$page = new \Racecore\GATracking\Tracking\Page();
$page->setDocumentPath('/test/pageview/blub.jpg');
$page->setDocumentTitle('Test Image Title');
$tracking->addTracking($page);
// Do the Job!
Try {
$tracking->send();
echo 'success';
} Catch (Exception $e) {
echo 'Error: ' . $e->getMessage() . '<br />' . "\r\n";
echo 'Type: ' . get_class($e);
}否则,您可以使用其他伟大的存储库,请看这里
https://stackoverflow.com/questions/24882173
复制相似问题