jeffersongoncalves/laravel-mixpanel
Composer 安装命令:
composer require jeffersongoncalves/laravel-mixpanel
包简介
This Laravel package seamlessly integrates Mixpanel analytics into your Blade templates. Easily track user interactions and product usage directly within your Laravel application using the Mixpanel JavaScript SDK, with all configuration managed via database settings.
README 文档
README
Laravel Mixpanel
This Laravel package seamlessly integrates the Mixpanel JavaScript SDK into your Blade templates. Easily track user interactions, page views, and product usage directly within your Laravel application, with all configuration managed via database settings using spatie/laravel-settings.
Requirements
- PHP 8.2+
- Laravel 11+
- spatie/laravel-settings configured (the
settingstable must exist)
Installation
Install the package via composer:
composer require jeffersongoncalves/laravel-mixpanel
If you haven't already, publish the spatie/laravel-settings migration to create the settings table:
php artisan vendor:publish --provider="Spatie\LaravelSettings\LaravelSettingsServiceProvider" --tag="migrations"
Then publish and run the Mixpanel settings migration:
php artisan vendor:publish --tag=mixpanel-settings-migrations php artisan migrate
Usage
Add the Mixpanel script to your Blade layout (typically before </head>):
@include('mixpanel::script')
Configuring Settings
Settings are stored in the database and can be managed via code:
use JeffersonGoncalves\Mixpanel\Settings\MixpanelSettings; $settings = app(MixpanelSettings::class); $settings->project_token = 'YOUR_MIXPANEL_PROJECT_TOKEN'; $settings->save();
Data Residency
Mixpanel supports data residency in the EU and India. Set the api_host accordingly:
// EU Data Residency $settings->api_host = 'https://api-eu.mixpanel.com'; $settings->save(); // India Data Residency $settings->api_host = 'https://api-in.mixpanel.com'; $settings->save();
Proxy Configuration
To route Mixpanel requests through your own proxy:
$settings->api_host = 'https://proxy.yourdomain.com'; $settings->custom_lib_url = 'https://proxy.yourdomain.com/lib.min.js'; $settings->save();
Available Settings
| Property | Type | Default | Description |
|---|---|---|---|
project_token |
?string |
null |
Your Mixpanel project token (required for tracking) |
api_host |
?string |
null |
Custom API endpoint for data residency (EU: https://api-eu.mixpanel.com, India: https://api-in.mixpanel.com) or proxy |
custom_lib_url |
?string |
null |
Custom library URL for proxy setups |
debug |
bool |
false |
Enable debug logging to browser console |
autocapture |
bool |
true |
Automatically capture clicks, inputs, scrolls, and other user interactions |
track_pageview |
string |
'true' |
Track page views automatically. Values: 'true', 'false', 'full-url', 'url-with-path-and-query-string', 'url-with-path' |
persistence |
string |
'cookie' |
Storage method for super properties ('cookie' or 'localStorage') |
cookie_expiration |
int |
365 |
Cookie lifespan in days |
secure_cookie |
bool |
false |
Only transmit cookies over HTTPS |
cross_subdomain_cookie |
bool |
true |
Enable cookie persistence across subdomains |
ip |
bool |
true |
Use IP address for geolocation data |
property_blacklist |
?string |
null |
Comma-separated list of properties to exclude from tracking |
opt_out_tracking_by_default |
bool |
false |
Initialize with tracking disabled (for GDPR/privacy compliance) |
stop_utm_persistence |
bool |
false |
Disable automatic UTM parameter retention |
record_sessions_percent |
int |
0 |
Percentage of sessions to record (0-100) |
record_heatmap_data |
bool |
false |
Enable heatmap data collection |
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
jeffersongoncalves/laravel-mixpanel 适用场景与选型建议
jeffersongoncalves/laravel-mixpanel 是一款 基于 Blade 开发的 Composer 扩展包,目前已累计 30 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「analytics」 「mixpanel」 「laravel」 「tracking」 「laravel-mixpanel」 「jeffersongoncalves」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jeffersongoncalves/laravel-mixpanel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jeffersongoncalves/laravel-mixpanel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jeffersongoncalves/laravel-mixpanel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Wrapper for the Mixpanel Data Export API.
Mixpanel Service Provider for lumen
Analytics chooser extensions for site settings.
A Laravel Nova Card to show Fathom Analytics stats.
Client for tracking events with Mixpanel Analytics
Send application events to analytics services and data-warehouse.
统计信息
- 总下载量: 30
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 31
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-23
