soee / googletagmanager
Easily integrates Google Tag Manager code with your Neos website.
Installs: 88
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:neos-plugin
Requires
- neos/neos: ~4.0
This package is auto-updated.
Last update: 2025-01-10 01:38:43 UTC
README
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
- e-mail: kontakt@soee.pl
- www: soee.pl
- twitter: @marcinsagol
License
This package is released under MIT license