Code Monkey home page Code Monkey logo

google-tag-manager-plugin's Introduction

Google Tag Manager plugin for Sylius eCommerce Platform

License Version Build

Related plugins

Installation

1. Composer

composer require stefandoorn/google-tag-manager-plugin

2. Load bundle

Add to the bundle list:

new GtmPlugin\GtmPlugin(),

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 events. Make sure the following 'sonata_block_render_events' are present in your views:

  • sylius.shop.layout.javascripts
  • sylius.shop.layout.head
  • sylius.shop.layout.before_body
  • sylius.shop.layout.after_body

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.

google-tag-manager-plugin's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar kgonella avatar lruozzi9 avatar markbeazley avatar pamil avatar stefandoorn avatar tuxes3 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.