gorriecoe/silverstripe-gtm

A simple module that adds google tag manager snippets to silverstripe.

Installs: 3 063

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:silverstripe-vendormodule

1.3.1 2020-04-13 08:09 UTC

This package is auto-updated.

Last update: 2021-06-13 11:57:24 UTC


README

A simple module that adds google tag manager snippets to silverstripe.

Installation

Composer is the recommended way of installing SilverStripe modules.

composer require gorriecoe/silverstripe-gtm

Requirements

  • silverstripe/cmframework ^4.0

Maintainers

Config

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.

Options

Define the tab to insert the gtm field into.

SilverStripe\SiteConfig\SiteConfig:
  gtm_tab: 'SomeTabName' // Defaults to 'Main'

Usage

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>

CSP - Content Security Policy

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