定制 krizon/php-ga-measurement-protocol 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

krizon/php-ga-measurement-protocol

最新稳定版本:v1.0.0

Composer 安装命令:

composer require krizon/php-ga-measurement-protocol

包简介

Easy use of the Google Analytics Measurement Protocol in PHP

README 文档

README

Build Status Scrutinizer Quality Score Code Coverage Latest Stable Version Total Downloads Latest Unstable Version License

A full featured php client for the Google Analytics Measurment Protocol API. Build upon the shoulders of the great Guzzle.

See https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide

Installation

Use Composer to add this library to your dependencies:

$ composer require krizon/php-ga-measurement-protocol

Features

  • Page tracking
  • Event tracking
  • Ecommerce tracking
  • Social interactions tracking
  • Exception tracking
  • User timing tracking
  • App tracking
  • Non-blocking requests (todo)

Usage

$config = array(
    'ssl' => true // Enable/Disable SSL, default false
);
$client = Krizon\Google\Analytics\MeasurementProtocol\MeasurementProtocolClient::factory($config);
$client->pageview(array(
    'tid' => 'UA-XXXX-XXXX', // Tracking Id 
    'cid' => 'XXXX-XXXXX-XXXXX', // Customer Id
    'dh' => 'domain.do',
    'dp' => '/php-ga-measurement-protocol/phpunit-test',
    'dt' => 'PHP GA Measurement Protocol'
));

Testing

Before you can run the tests make sure you installed the dependencies using composer:

$ composer install

PHPUnit itself is included in the dependencies so now you can call:

$ vendor/bin/phpunit

We have two types of tests:

  • Tests with mocked 200 OK response, @group __nogroup__. This type of tests are used tor testing required fields, asserting classtypes etc.;
  • Tests that do real calls to the Google API, @group internet. The Google API itself always returns a 200 OK so to be sure the requests are transferred and handled correctly you can run the tests of group 'internet'. Before running this group make sure you've configured the correct tracking id in the phpunit.xml configuration by setting the env variable tracking_id. This group is excluded by default but you can run this tests by calling: $ vendor/bin/phpunit --group internet

Contributors

统计信息

  • 总下载量: 538.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 111
  • 点击次数: 2
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 109
  • Watchers: 8
  • Forks: 23
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-11-01