hadiabedzadeh/laravel-gtm-load-logger 问题修复 & 功能扩展

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

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

hadiabedzadeh/laravel-gtm-load-logger

Composer 安装命令:

composer require hadiabedzadeh/laravel-gtm-load-logger

包简介

Log the real loading status of Google Tag Manager directly into your Laravel database.

README 文档

README

Log the real loading status of Google Tag Manager directly into your Laravel database.

This package helps you detect when GTM:

  • loads successfully
  • fails due to network, DNS, or AdBlock
  • times out
  • partially loads

It is useful for debugging analytics issues in countries where GTM may be blocked or unstable.

Installation

composer require hadiabedzadeh/laravel-gtm-load-logger

Publish config and migration

php artisan vendor:publish --tag=gtm-load-logger-config
php artisan vendor:publish --tag=gtm-load-logger-migrations
php artisan migrate

Environment

GTM_LOAD_LOGGER_ENABLED=true
GTM_LOAD_LOGGER_ID=GTM-W8W7BWH
GTM_LOAD_LOGGER_TIMEOUT=7000
GTM_LOAD_LOGGER_TABLE=gtm_load_logs
GTM_LOAD_LOGGER_ROUTE_PREFIX=gtm-load-logger

Usage

Put this inside your main Blade layout <head>:

@include('gtm-load-logger::script')

Put this immediately after <body> if you also want the normal GTM noscript fallback:

@include('gtm-load-logger::noscript')

Route

The package automatically registers:

POST /gtm-load-logger/log
GET  /gtm-load-logger/log

Route name:

route('gtm-load-logger.log')

Logged fields

The package stores:

  • GTM ID
  • status: success, partial, error, timeout, unknown
  • reason
  • page URL
  • user agent
  • visitor IP
  • noscript flag
  • timestamps

Example SQL analytics

SELECT
    COUNT(*) AS total,
    SUM(CASE WHEN status = 'success' THEN 1 ELSE 0 END) AS success,
    SUM(CASE WHEN status <> 'success' OR status IS NULL THEN 1 ELSE 0 END) AS failed,
    ROUND(100.0 * SUM(CASE WHEN status = 'success' THEN 1 ELSE 0 END) / COUNT(*), 2) AS success_percent,
    ROUND(100.0 * SUM(CASE WHEN status <> 'success' OR status IS NULL THEN 1 ELSE 0 END) / COUNT(*), 2) AS failed_percent
FROM gtm_load_logs;

SQL Server table

Laravel migration is recommended. If you want a manual SQL Server table:

CREATE TABLE [dbo].[gtm_load_logs](
    [id] [bigint] IDENTITY(1,1) NOT NULL,
    [gtm_id] [nvarchar](50) NULL,
    [status] [nvarchar](20) NOT NULL,
    [reason] [nvarchar](max) NULL,
    [url] [nvarchar](max) NULL,
    [user_agent] [nvarchar](max) NULL,
    [ip] [varchar](45) NULL,
    [noscript_enabled] [bit] NOT NULL CONSTRAINT [DF_gtm_load_logs_noscript_enabled] DEFAULT 0,
    [created_at] [datetime2](7) NULL,
    [updated_at] [datetime2](7) NULL,
    PRIMARY KEY CLUSTERED ([id] ASC)
);

Packagist publishing checklist

  1. Create a GitHub repository, for example: hadiabedzadeh/laravel-gtm-load-logger
  2. Push this package code.
  3. Create a release tag:
git tag v1.0.0
git push origin v1.0.0
  1. Submit the GitHub repository URL in Packagist.
  2. Install it in Laravel projects:
composer require hadiabedzadeh/laravel-gtm-load-logger

License

MIT

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固