irazasyed/laravel-gamp
Composer 安装命令:
composer require irazasyed/laravel-gamp
包简介
Send analytics data to Google Analytics from Laravel. A package for GA Measurement Protocol API
关键字:
README 文档
README
Laravel GAMP: Google Analytics Measurement Protocol Package for Laravel & Lumen.
Send data to Google Analytics from Laravel/Lumen. Supports all GA Measurement Protocol API methods.
Quick start
Install
Step 1: Install Through Composer
$ composer require irazasyed/laravel-gamp
(Lumen) Add the Service Provider
Open bootstrap/app.php and register the service provider by adding:
$app->register(Irazasyed\LaravelGAMP\LaravelGAMPServiceProvider::class);
Step 2: Publish Config
Open your terminal window and fire the following command to publish config file to your config directory:
$ php artisan vendor:publish --provider="Irazasyed\LaravelGAMP\LaravelGAMPServiceProvider"
Usage
Open config file config/gamp.php and set the tracking_id with your Google Analytics tracking / web property ID.
Refer the config file for other default configuration settings.
This Package adds Laravel Support to GA Measurement Protocol PHP Library by THE ICONIC. It's simply a wrapper around the library with default config for easier usage with Laravel. So all the methods listed here are available and will work seamlessly.
Example Usage
Send a Page view hit:
use Irazasyed\LaravelGAMP\Facades\GAMP; $gamp = GAMP::setClientId( '123456' ); $gamp->setDocumentPath( '/page' ); $gamp->sendPageview();
Send an Event:
use Irazasyed\LaravelGAMP\Facades\GAMP; $gamp = GAMP::setClientId( '123456' ); $gamp->setEventCategory('Blog Post') ->setEventAction('Create') ->setEventLabel('Using GAMP In Laravel') ->sendEvent();
Config Overview
Open the config file for detailed comments for each option.
Set your Google Analytics Tracking / Web Property ID in tracking_id key [REQUIRED]
'tracking_id' => 'UA-XXXX-Y',
All other configuration options are optional, use as per your requirements.
To send data over SSL, set is_ssl to true.
'is_ssl' => true,
To disable library in Staging/Dev env (Prevents the library from sending any hits to GA), set is_disabled to true.
'is_disabled' => true,
To Anonymize IP, set anonymize_ip to true.
'anonymize_ip' => true,
To Make Async Requests, set async_requests to true.
'async_requests' => true,
...
Refer the library's documentation for other remaining methods and examples, they all work.
Note: You don't have to use the protocol version, tracking id, anonymize ip and async request (non-blocking) methods from the original library as they're automatically set in Service Provider when the package is initialized based on the config file. As long as you update the config file with correct settings, it should work just fine.
Additional information
Any issues, please report here
Credits
- Syed Irfaq R. - For Laravel and Lumen Bridge.
- THE ICONIC - For GA Measurement Protocol PHP Library.
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
irazasyed/laravel-gamp 适用场景与选型建议
irazasyed/laravel-gamp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.6M 次下载、GitHub Stars 达 332, 最近一次更新时间为 2015 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「analytics」 「google analytics」 「tracking」 「measurement protocol」 「laravel google analytics」 「ga measurement protocol」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 irazasyed/laravel-gamp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 irazasyed/laravel-gamp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 irazasyed/laravel-gamp 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP SDK for the Parcel Monkey UK API
Analytics chooser extensions for site settings.
A Laravel Nova Card to show Fathom Analytics stats.
Magento 2 Social Login extension is designed for quick login to your Magento 2 store without procesing complex register steps
Audit changes of your Eloquent models in Laravel/Lumen
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
统计信息
- 总下载量: 1.6M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 335
- 点击次数: 26
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-27
