quadcompanies/google-analytics 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

quadcompanies/google-analytics

最新稳定版本:v1.1.0

Composer 安装命令:

composer require quadcompanies/google-analytics

包简介

A simple Laravel package to integrate Google Analytics gtag.js

README 文档

README

A simple and easy-to-use Laravel package for integrating Google Analytics (gtag.js) into your application.

Installation

You can install the package via composer:

composer require quadcompanies/google-analytics
php artisan vendor:publish --provider="QuadCompanies\GoogleAnalytics\GoogleAnalyticsServiceProvider" --tag="config"

This is the contents of the published config file:

return [
    /*
     * The Google Analytics Measurement ID (usually starts with 'G-')
     */
    'measurement_id' => env('GOOGLE_ANALYTICS_MEASUREMENT_ID'),

    /*
     * Whether or not to enable Google Analytics.
     */
    'enabled' => env('GOOGLE_ANALYTICS_ENABLED', true),

    /*
     * Additional Tag IDs that should be loaded.
     */
    'tag_ids' => [],
];

Usage

Environment Setup

Add your Google Analytics Measurement ID to your .env file:

GOOGLE_ANALYTICS_MEASUREMENT_ID=G-XXXXXXXXXX

Blade Directive

To add the Google Analytics script to every page, add the @googleAnalytics directive to the <head> section of your main layout file (e.g., resources/views/layouts/app.blade.php):

<!DOCTYPE html>
<html>
<head>
    @googleAnalytics()
    ...
</head>
...
</html>

Dynamic Parameters

You can also pass a custom measurement ID and additional tag IDs directly through the directive:

@googleAnalytics('G-CUSTOM-ID', ['G-TAG-1', 'G-TAG-2'])

Testing

Coming soon...

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 137
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固