soee/googletagmanager

Last activity 21 Sep 2019 42
composer require soee/googletagmanager

Easily integrates Google Tag Manager code with your Neos website.

1.0.0

Version
1.0.0
Type
neos-plugin
Release Date
May 26, 2018 08:23
Source
git
Distribution
zip
Requires
GPL-3.0+
  • #flow
  • #manager
  • #google
  • #seo
  • #tag
  • #neos
  • #integration
  • #soee
5755e2b70f4d3f4ed99c3b75fc31b4e24be5a021

soee - Google Tag Manager

Easily integrates Google Tag Manager installation code with your Neos website.

Installation

Add manually soee-googletagmanager package to your composer.json file to type in command line:

composer require soee/googletagmanager

Configuration

By default Google Tag Manager codes are rendered only if you have identifier set through configuration:

Soee:
  GoogleTagManager:
    identifier: 'MY-GOOGLETAGMANAGER-IDENTIFIER'

Customizations

The whole process and integration code is highly customizable. This package defines 2 new nodetypes:

Soee.GoogleTagManager:Code - used to render Google Tag Manager code inside head section Soee.GoogleTagManager:NoscriptCode - used to render noscript Google Tag Manager code after body opening tag

Both Code and NoscriptCode inherit from Neos.Fusion:Tag so you can check current code and customize it as you will.

Important:

You probably do not want to render Google Tag Manager codes inside development or testing environment. This package will help you with that but to do so we are checking Flow context name like this:

@if.inProductionEnvironment = ${Configuration.setting('Neos.Flow.core.context') == 'Production' ? true:false}

While this should work just fine in most cases it is still recommended to use your own variable that defines current environment. For example if your site package name is Vendor.Site than you could create 2 Settings.yaml files: one would be Configuration\Production\Settings.yaml and second Configuration\Development\Settings.yaml (similar for any extra environment). Than inside this 2 files you can configure environment configuration option:

for Production it could be:

Vendor:
  Site:
    environment: 'Production'

for Development it could be:

Vendor:
  Site:
    environment: 'Development'

Than you can use it to decide if Google Tag Manager code should be rendered like this:

Neos.Neos:Page {
  ...
  googleTagManagerCode {
    @if.inProductionEnvironment = ${Configuration.setting('Vendor.Site.environment') == 'Production' ? true:false}
  }
  ...
  googleTagManagerNoscriptCode {
    @if.inProductionEnvironment = ${Configuration.setting('Vendor.Site.environment') == 'Production' ? true:false}
  }
  ...
}

Author - Marcin Sągol

License

This package is released under MIT license

The content of the readme is provided by Github
The same vendor provides 3 package(s).