moriony/ga-measurement-protocol-client

Google Analytics Measurement Protocol PHP 客户端包装器

0.0.1 2014-09-04 13:31 UTC

This package is auto-updated.

Last update: 2024-08-25 18:45:17 UTC


README

Build Status Coverage Status SensioLabsInsight Latest Stable Version Total Downloads Latest Unstable Version License

基于 krizon/php-ga-measurement-protocol 的 Google Analytics Measurement Protocol PHP 客户端包装器

参阅 Google Analytics Measurement Protocol 文档

安装

使用 Composer 将此库添加到您的依赖项中

$ php composer.phar require moriony/ga-measurement-protocol-client:dev-master

用法

use \Moriony\Google\Analytics\MeasurementProtocol\Client;

$client = new Client([
    Client::OPT_TRACKING_ID => 'UA-XXXXXXXXX-Y',
    Client::OPT_SSL => true,
]);

$response = $client->createEvent()
    ->setCustomerId(555)
    ->setCategory('video')
    ->setAction('play')
    ->setLabel('holiday')
    ->setValue(300)
    ->track();

测试

在运行测试之前,请确保您已使用 composer 安装了依赖项

$ composer install

PHPUnit 本身包含在依赖项中,因此现在您可以调用

$ vendor/bin/phpunit