承接 mainaero/yii2-gtm-widget 相关项目开发

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

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

mainaero/yii2-gtm-widget

Composer 安装命令:

composer require mainaero/yii2-gtm-widget

包简介

Google Tag Manager Widget for the Yii2 Framework

README 文档

README

Build Status Maintainability Test Coverage

A Yii2 extensions which provides a widget to render Google Tag Manager <script> and <noscript> snippets based on Yii2 params configuration. Further you can register it as component and use it to trigger dataLayer.push requests.

Install

Using composer:

composer require "mainaero/yii2-gtm-widget"

Configuration

Add in your params-local.php file:

'gtm_id' => '<YOUR_GTM_ID_WITHOUT_GTM_PREFIX> (required)',
'gtm_env' => '<YOUR_ENVIRONMENT_QUERY_STRING> (optional)'

E.g.:

'gtm_id' => '1A2B3CD',
'gtm_env' => '&gtm_auth=<TOKEN>w&gtm_preview=<ENV_ID>&gtm_cookies_win=x'

If you don't set the gtm_id param this widget will return an empty string.

As Component

If you want to use it as component add following code to your main.php config:

'components' => [
...
  'gtmDataLayerPush' => [
    'class' => 'mainaero\yii\gtm\component\DataLayerPush'
  ],
...
]

Usage

In your view file:

<?php
use mainaero\yii\gtm\widget\GTM;
...

Render a <script> snippet:

<?= GTM::widget(); ?>

which renders:

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl+'<YOUR_ENVIRONMENT_QUERY_STRING>';f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-<YOUR_ID>');</script>
<!-- End Google Tag Manager -->

Render a <noscript> snippet:

<?= GTM::widget(['type' => 'noscript']); ?>

which renders:

<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-<YOUR_ID><YOUR_ENVIRONMENT_QUERY_STRING>"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->

Use to trigger dataLayer.push

In your controller add seomthing with:

Yii::$app->gtmDataLayerPush->add(['event' => 'myEvent', 'eventCategory' => 'myCategory']);

Somewhere in your view or layout file output it with:

<?= GTM::widget(['type' => 'dataLayerPush']) ?>

You can leave this snipped in your layout file as it will only render something if you have added something before.

mainaero/yii2-gtm-widget 适用场景与选型建议

mainaero/yii2-gtm-widget 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25.44k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 01 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「google」 「yii2」 「gtm」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mainaero/yii2-gtm-widget 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mainaero/yii2-gtm-widget 我们能提供哪些服务?
定制开发 / 二次开发

基于 mainaero/yii2-gtm-widget 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-29