Adds single field to CMS settings section to hold GA or GTM code. Template snippets need to be inserted to theme templates manually.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 4


2.0.3 2022-08-05 01:26 UTC

This package is auto-updated.

Last update: 2024-05-05 05:54:42 UTC


Adds support for a single-field configuration of GA/GTM code within the CMS.
Comes with Google snippets that need to be included in your theme's templates.


  • SilverStripe 4.0 and above



$ composer require chrometoaster/ga-gtm-singlefield

Alternatively, you can also install the module manually by placing a copy to the root folder of your site.

Run dev/build either via opening the url http://<your-host>/dev/build in a browser or by running the dev/build via a CLI.

Theme integration

Place two template includes into your theme's main template, e.g.


<% include GA_GTM_head %> as close to the opening <head> tag as possible:

<head itemscope itemtype="">
    <meta charset="utf-8">
    <title itemprop="name">$Title</title>

    <% include Chrometoaster\GA_GTM\GA_GTM_head %>


<% include Chrometoaster\GA_GTM\GA_GTM_body %> directly after the opening <body> tag:

    <% include Chrometoaster\GA_GTM\GA_GTM_body %>


You will see a new 'GA & GTM' tab with a single field for a GA or GTM code under Settings in the CMS.
Insert a valid GA or GTM code and check if it's getting output to the resulting markup correctly.


For details of updates, bugfixes, and features, please see the changelog.


  • Replace template includes with TemplateGlobalProvider or Controller function.
  • Investigate options for automatically inserting the necessary tags to the markup, e.g. extending the $MetaTags functionality or using Requirements backend.