stefandoorn/google-tag-manager-plugin 问题修复 & 功能扩展

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

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

stefandoorn/google-tag-manager-plugin

最新稳定版本:v2.0.0-alpha.2

Composer 安装命令:

composer require stefandoorn/google-tag-manager-plugin

包简介

Google Tag Manager plugin for Sylius.

README 文档

README

License Version Build

Related plugins

Installation

1. Composer

composer require stefandoorn/google-tag-manager-plugin

2. Load bundle

Add to the bundle list (config/bundles.php):

    GtmPlugin\GtmPlugin::class => ['all' => true],

3. Follow installation instructions of required sub bundle (https://github.com/xyNNN/GoogleTagManagerBundle)

Add to your configuration:

google_tag_manager:
    enabled: true
    id: "GTM-XXXXXX"
    autoAppend: false

And also configure the features you would like to use from this plugin:

gtm:
    inject: true
    features:
        environment: true
        route: true
        context: true
        events: true

In case you set autoAppend to false & also disable the inject setting inside this plugin, you have to manage loading of the GTM container yourself.

In case you set autoAppend to false & set inject to true, be aware of the following:

Required output to your HTML (head, body & footer) are done through Sylius Twig Hooks. The following Sylius Twig Hooks are used:

  • sylius_shop.base.head
  • sylius_shop.base.header
  • sylius_shop.base.offcanvas
  • sylius_shop.base#javascripts

You can dump the default configuration using:

bin/console config:dump-reference GtmPlugin

5. Install assets (optional: only if you want to use events feature)

bin/console assets:install 
bin/console sylius:install:assets
bin/console sylius:theme:assets:install

Features

  • environment: Send Symfony/Sylius environment to GTM
  • route: Send Symfony/Sylius route to GTM
  • context: Send Sylius context information to GTM (currency, locale, channel)
  • events: See below - allows you to register events easily from inside HTML using JS.

Usage

Register events from JS

var event = new GaEvent('category');
event.register(action, label, value);

Make sure also to listen for this specific event inside your GTM configuration.

统计信息

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

GitHub 信息

  • Stars: 23
  • Watchers: 2
  • Forks: 14
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-27