项目作者: yiimaker

项目描述 :
Google Analytics (Measurement Protocol)
高级语言: PHP
项目地址: git://github.com/yiimaker/yii2-google-analytics.git
创建时间: 2016-12-04T14:40:30Z
项目社区:https://github.com/yiimaker/yii2-google-analytics

开源协议:Apache License 2.0

下载


Google Analytics (Measurement Protocol)

Google Analytics (Measurement Protocol)

Installation

The preferred way to install this extension is through composer.

Either run

  1. php composer.phar require --prefer-dist yiimaker/yii2-google-analytics "*"

or add

  1. "yiimaker/yii2-google-analytics": "*"

to the require section of your composer.json file.

Example

Initialize

  1. $analytics = \Yii::createObject([
  2. 'class' => \ymaker\google\analytics\mp\Analytics::className(),
  3. 'v' => 1, // Protocol version. Default value: 1
  4. 'tid' => 'UA-XXXX-Y' // Tracking ID / Web Property ID
  5. 'cid' => '35009a79-1a05-49d7-b876-2b884d0f825b' // Client ID. Random UUID (http://www.ietf.org/rfc/rfc4122.txt)
  6. ]);

Usage

  1. /** @var yii\httpclient\Response $responce */
  2. $responce = $analytics->send([
  3. 't' => 'event', // Hit Type.
  4. 'ec' => 'video', // Event Category.
  5. 'ea' => 'play', // Event Action.
  6. 'el' => 'holiday', // Event label.
  7. 'ev' => 300, // Event value.
  8. ]);

For more information, refer to the API official documentation.