neomrc/google-analytics
Composer 安装命令:
composer require neomrc/google-analytics
包简介
Google Analytics Measurement Protocol Package
README 文档
README
This package helps developers to make google analytics dispatches easy. Based on google's documentation: https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
To start do:
composer require neomrc/google-analytics
This is a pretty straightforward service. Here is a sample of an event hit:
use Neomrc\GoogleAnalytics;
...
try {
$tracker = new GoogleAnalytics()->track('event');
$tracker->setCategory('categoryFoo');
->setAction('actionBar');
->send();
} catch (\Exception $e) {
// tracker sending failed
}
To instantiate:
new GoogleAnalytics()->track(
<enter hit type here>);
Set Tracking ID:
->setTrackingId(
<trackingId>)
Set Client ID:
->setClientId(
<clientId>)
Set User ID:
->setUserId(
<userId>)
This will initialize the hit type class in which you can set the values by using the methods below
Possible hit types
Note: types are case-sensitive
eventpageview
Pageview
| Methods | Required | Value Type |
|---|---|---|
setDocumentHostname |
false |
string |
setPage |
false |
string |
setTitle |
false |
string |
Event
| Methods | Required | Value Type |
|---|---|---|
setCategory |
true |
string |
setAction |
true |
string |
setLabel |
false |
string |
setValue |
false |
string |
To send/dispatch the analytics object
->send(
<optional array of data here ['key' => 'value']>)
This is my first package. I hope someone will find this useful.
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-13