百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

laravel-gamp

> 后端框架
开源

Laravel Google Analytics 测量协议包

331 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Laravel Google Analytics 测量协议包

Laravel-GAMP Package

Join PHP Chat Chat on Telegram Laravel & Lumen Package Latest Version on Packagist Software License Total Downloads

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.

Laravel GAMP

Quick start

Install

Step 1: Install Through Composer

bash
$ composer require irazasyed/laravel-gamp

(Lumen) Add the Service Provider

Open bootstrap/app.php and register the service provider by adding:

php
$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:

bash
$ 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:

php
use Irazasyed\LaravelGAMP\Facades\GAMP;

$gamp = GAMP::setClientId( '123456' );
$gamp->setDocumentPath( '/page' );
$gamp->sendPageview();

Send an Event:

php
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]

php
'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.

php
'is_ssl' => true,

To disable library in Staging/Dev env (Prevents the library from sending any hits to GA), set is_disabled to true.

php
'is_disabled' => true,

To Anonymize IP, set anonymize_ip to true.

php
'anonymize_ip' => true,

To Make Async Requests, set async_requests to true.

php
'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.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPanalyticsga-measurement-protocolgampgoogle-analytics

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架