Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yiimaker/yii2-google-analytics
Google Analytics (Measurement Protocol)
https://github.com/yiimaker/yii2-google-analytics
google-analytics measurement-protocol yii2-extension
Last synced: about 1 month ago
JSON representation
Google Analytics (Measurement Protocol)
- Host: GitHub
- URL: https://github.com/yiimaker/yii2-google-analytics
- Owner: yiimaker
- License: apache-2.0
- Created: 2016-12-04T14:40:30.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-04T14:47:39.000Z (about 8 years ago)
- Last Synced: 2024-11-13T14:54:37.307Z (about 1 month ago)
- Topics: google-analytics, measurement-protocol, yii2-extension
- Language: PHP
- Size: 6.84 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Google Analytics (Measurement Protocol)
=======================================
Google Analytics (Measurement Protocol)Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist yiimaker/yii2-google-analytics "*"
```or add
```
"yiimaker/yii2-google-analytics": "*"
```to the require section of your `composer.json` file.
Example
-----
Initialize
```php
$analytics = \Yii::createObject([
'class' => \ymaker\google\analytics\mp\Analytics::className(),
'v' => 1, // Protocol version. Default value: 1
'tid' => 'UA-XXXX-Y' // Tracking ID / Web Property ID
'cid' => '35009a79-1a05-49d7-b876-2b884d0f825b' // Client ID. Random UUID (http://www.ietf.org/rfc/rfc4122.txt)
]);
```
Usage
```php
/** @var yii\httpclient\Response $responce */
$responce = $analytics->send([
't' => 'event', // Hit Type.
'ec' => 'video', // Event Category.
'ea' => 'play', // Event Action.
'el' => 'holiday', // Event label.
'ev' => 300, // Event value.
]);
```For more information, refer to the [API official documentation](https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide).