mmhk / laravel-ga-embed
google analytics embed dashboard for laravel
0.2
2019-10-11 07:25 UTC
Requires
- php: >=7.0.0
- google/apiclient: ^2.0@dev
- laravel/framework: 5.5.*
This package is auto-updated.
Last update: 2024-11-11 17:55:22 UTC
README
google analytics embed dashboard for laravel
Install
composer require mmhk/laravel-ga-embed
Config
-
配置
ServiceProvider
config/app.php
<?php return [ 'providers' => [ //... MMHK\GA\GoogleAnalyticsEmbedServiceProvider::class, ], 'aliases' => [ //... 'GAEmbed' => MMHK\GA\GAEmbed::class, ], ];
如果是
Laravel 5.5
以上版本,直接composer update
之后会自动发现ServiceProvider
- 发布相关资源文件
php artisan vendor:publish --provider="MMHK\GA\GoogleAnalyticsEmbedServiceProvider"
- 修改配置
config/ga-embed.php
<?php return [ 'config-file' => base_path('resources/key.json'), //此为 Google API Console中下载的json文件 ];
- 使用
<?= GAEmbed::render($view_id); ?>
$view_id
为 google analytics 中 Admin -> Account -> Property -> View -> View Settings 中找到。
参考
ref: https://developers.google.com/analytics/devguides/config/mgmt/v3/quickstart/service-php