swvjeff/laravel-analytics
Composer 安装命令:
composer require swvjeff/laravel-analytics
包简介
A simple package that allows you to define multiple Google Analytics tracking IDs for your website
README 文档
README
A simple package that allows you to define multiple Google Analytics tracking IDs for your website
Installation
This package can be installed using Composer:
composer require swvjeff/laravel-analytics
Add your primary Analytics Tracking ID to your .env file
ANALYTICS_TRACKING_ID="UA-XXXXXXX-X"
If you want to add multiple tracking IDs, you can publish the config file of this package with the following command and hard-code the tracking IDs into the secondary_tracking_ids array:
php artisan vendor:publish --provider="Swvjeff\Analytics\AnalyticsServiceProvider"
The following config file will be published in config/analytics.php
return [ 'tracking_id' => env('ANALYTICS_TRACKING_ID'), 'secondary_tracking_ids' => [] ];
Additionally, you can add tracking IDs programmatically by calling \Analytics::addTrackingId('UA-XXXXXXX-X').
Example
Save your primary tracking ID to your .env file, the package will automatically detect it
ANALYTICS_TRACKING_ID="UA-9999999-1"
Add any additional tracking IDs to
use Analytics; // Add any additional GA tracking IDs programmatically Analytics::addTrackingId('UA-9999999-2'); Analytics::addTrackingId('UA-9999999-3');
Render your Analytics tracking script
<!DOCTYPE html> <html> <head> {!! Analytics::render() !!} </head>
Changelog
Please see CHANGELOG for more information what has changed recently.
Security
If you discover any security related issues, please email jeff@selectwv.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-12