This package allows adding Google Analytics and the Google Tag Manager to a Neos CMS website.
-
Run the following command f.e. in your site package:
composer require --no-update neos/googleanalytics
-
Update your dependencies by running the following command in your project root folder:
composer update
To actually track visits with Google Analytics, some JavaScript with the tracking ID has to be included in the markup. You can do this manually in your template, but the easier way is to set up tracking for each site in the Analytics integration.
Neos:
GoogleAnalytics:
sites:
## All site specific settings are indexed by site node name
neosSiteName:
analytics:
id: 'G-XXXXXXXXXX'Instead of using the Google Analytics tracking code, you can integrate the Google Tag Manager the same way:
Neos:
GoogleAnalytics:
sites:
neosSiteName:
tagManager:
id: 'GTM-XXXXX'Note: If you configure both, a container and an Analytics ID, only the Tag Manager is included.
It is also possible to define default values for all sites. These will be merged with any site specific settings.
Neos:
GoogleAnalytics:
default:
analytics:
id: 'G-XXXXXXXXXX'You can disable tracking for a site by either setting the id to false (this is the default value), or leaving it blank.
Neos:
GoogleAnalytics:
sites:
neosSiteName:
tagManager:
id: falseIf you are using the Google Analytics tracking code, you can also add additional parameters e.g. anonymize_ip set to true.
These parameters are added automatically as JSON to the gtag. The default setting is no parameters.
Neos:
GoogleAnalytics:
sites:
neosSiteName:
analytics:
id: 'G-XXXXXXXXXX'
parameters:
anonymize_ip: trueBy default the tracking code is added to the Neos.Neos:Page prototype automatically. If you want to place it
yourself, disable the automatic inclusion and use the Fusion prototypes directly:
Neos:
GoogleAnalytics:
sites:
neosSiteName:
addToPagePrototype: falseThe following Fusion prototypes are available:
Neos.GoogleAnalytics:TrackingCode.GArenders the gtag.js snippet for the configured Analytics ID.Neos.GoogleAnalytics:TrackingCode.GTM.Scriptrenders the Google Tag Manager script snippet.Neos.GoogleAnalytics:TrackingCode.GTM.NoScriptrenders the Google Tag Manager noscript fallback.Neos.GoogleAnalytics:TrackingCode.GTM.DataLayerpushes the givendataontowindow.dataLayer.
The tracking code is never rendered while working in a non-live workspace, e.g. in the Neos backend.
The statistics display inside the Neos backend (inspector "Stats" tab and the "Analytics" administration module) has been removed, because the underlying Google Analytics Reporting API (Universal Analytics) is no longer available. The package now only provides the tracking code integration.
If you referenced any of these in your own configuration, remove those references.
See LICENSE