A simple module that adds google tag manager snippets to silverstripe.
A simple module that adds google tag manager snippets to silverstripe.
Composer is the recommended way of installing SilverStripe modules.
composer require gorriecoe/silverstripe-gtm
GTM will check if your .env
file has defined GTM_ID
first. As follows:
GTM_ID="GTM-123456"
If GTM_ID has not been defined you can edit it in your CMS settings.
Define the tab to insert the gtm field into.
SilverStripe\SiteConfig\SiteConfig:
gtm_tab: 'SomeTabName' // Defaults to 'Main'
Insert $GTMscript
after the opening head tag and $GTMnoscript
after the opening body tag.
<!doctype html>
<html class="no-js" lang="en">
<head>
{$GTMscript}
...
</head>
<body>
{$GTMnoscript}
...
</body>
</html>
GTM checks for getNonce()
method in the current controller. If its avaiable it will produce a CSP compatible snippet.
This means GTM is works with Firesphere/csp-headers
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem