mmhk/laravel-ga-embed

google analytics embed dashboard for laravel

0.2 2019-10-11 07:25 UTC

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