承接 helick/gtm 相关项目开发

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

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

helick/gtm

Composer 安装命令:

composer require helick/gtm

包简介

The Helick Google Tag Manager plugin

README 文档

README

Latest Version on Packagist Total Downloads Software License Quality Score

Google Tag Manager integration.

Requirements

Make sure all dependencies have been installed before moving on:

Install

Install via Composer:

$ composer require helick/gtm

Update your application config by declaring the following:

Config::define('GTM_CONTAINER_ID', env('GTM_CONTAINER_ID'));

Update your env variables by declaring the following:

GTM_CONTAINER_ID=GTM-XXXX

Usage

To support the fallback iframe for devices without javascript add the following code just after the opening <body> tag in your theme:

<?php wp_body_open(); ?>

Data layer

Google Tag Manager offers a data layer which allows you pass arbitrary data that can be used to modify which tags are added to your site.

This plugin adds some default information such as post, tags and categories and provides a simple filter for adding in your own custom data.

add_filter('helick_gtm_data_layer', function (array $dataLayer) {
    $dataLayer['foo'] = 'bar';

    return $dataLayer;
});

Event tracking

To deactivate the event tracking you may declare the following:

add_filter('helick_gtm_enable_event_tracking', '__return_false');

By default the event listener script will look for the elements on the page with special data attributes in your markup and listen for the specified event to push to the data layer.

The data attributes are:

  • data-gtm-variable string Optionally override the default data layer variable name for this event.
  • data-gtm-on enum [click|submit|keyup|focus|blur] The JS event to listen for, defaults to 'click'.
  • data-gtm-event string The event name.
  • data-gtm-category string Optional group the event belongs to.
  • data-gtm-label string Optional human readable label for the event.
  • data-gtm-value number Optional numeric value associated with the event.
  • data-gtm-fields string Optional extra data provided as encoded JSON.

Example:

<button
    data-gtm-on="click"
    data-gtm-event="play"
    data-gtm-category="videos"
    data-gtm-label="Featured Promotional Video"
>
  Play video
</button>

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email evgenii@helick.io instead of using the issue tracker.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固