承接 jeffersongoncalves/laravel-gtm 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

jeffersongoncalves/laravel-gtm

最新稳定版本:2.0.1

Composer 安装命令:

composer require jeffersongoncalves/laravel-gtm

包简介

This plugin seamlessly integrates Google Tag Manager (GTM) into your website, enabling streamlined management and deployment of marketing tags, analytics, and tracking pixels. With easy-to-implement script inclusion and customizable options, it simplifies the process of monitoring user interactions

README 文档

README

Laravel Gtm

Laravel Google Tag Manager

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

This plugin seamlessly integrates Google Tag Manager (GTM) into your website, enabling streamlined management and deployment of marketing tags, analytics, and tracking pixels. With easy-to-implement script inclusion and customizable options, it simplifies the process of monitoring user interactions and gathering valuable insights without altering your site's core code. Perfect for marketers and developers looking to enhance their tracking capabilities with minimal effort.

Requirements

  • PHP 8.2+
  • Laravel 11.0+
  • spatie/laravel-settings ^3.0 (installed automatically)

Installation

You can install the package via composer:

composer require jeffersongoncalves/laravel-gtm

Run the migrations to create the settings table and seed the GTM settings:

php artisan migrate

Configuration

Setting your GTM ID

The GTM ID is stored in the database via spatie/laravel-settings. Configure it at runtime using any of the following approaches:

Via dependency injection

use JeffersonGoncalves\Gtm\Settings\GtmSettings;

$settings = app(GtmSettings::class);
$settings->gtm_id = 'GTM-XXXXXX';
$settings->save();

Via helper function

$settings = gtm_settings();
$settings->gtm_id = 'GTM-XXXXXX';
$settings->save();

Publishing the settings migration (optional)

If you need to customize the settings migration:

php artisan vendor:publish --tag=gtm-settings-migrations

Usage

Add the GTM head script inside your <head> tag, as high as possible:

@include('gtm::head')

Add the GTM body noscript immediately after the opening <body> tag:

@include('gtm::body')

Reading the current GTM ID

// Via helper
$gtmId = gtm_settings()->gtm_id;

// Via container
$gtmId = app(\JeffersonGoncalves\Gtm\Settings\GtmSettings::class)->gtm_id;

// Via Facade
$gtmId = \JeffersonGoncalves\Gtm\Facades\Gtm::gtm_id;

Updating the GTM ID at runtime

$settings = gtm_settings();
$settings->gtm_id = 'GTM-NEWID';
$settings->save();

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固