From e9740c05b1ae242206dc9e835f3ba527c1be4684 Mon Sep 17 00:00:00 2001 From: Andrew Mc Cormack Date: Thu, 26 Oct 2017 15:34:55 +0100 Subject: [PATCH] update readme with YML container config info --- README.md | 2 +- docs/installation/README.md | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index afb42cc..35bf898 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ A Silverstripe module to add Google Tag Manager Version 2 datalayer, event, and - [Installation](/docs/installation) - [Composer](/docs/installation#composer) - - [Controller and View](/docs/installation#controller-and-view) + - [Package Namespace](/docs/installation#package-namespace) - [Validating your Search Console property](/docs/installation#validating-your-search-console-property) - [Pushing Data](/docs/data) - [Pushing to the data layer](/docs/data#pushing-to-the-data-layer) diff --git a/docs/installation/README.md b/docs/installation/README.md index 804b964..932ff35 100644 --- a/docs/installation/README.md +++ b/docs/installation/README.md @@ -7,28 +7,31 @@ Add the following to your composer.json file ```json { "require": { - "cyber-duck/silverstripe-google-tag-manager": "1.0.*" + "cyber-duck/silverstripe-google-tag-manager": "4.0.*" } } ``` Run composer and then flush the Silverstripe cache (add ?flush=all to your URL and reload the page) -## Controller +## Package Namespace -Add the following method to the Page_Controller in your Page.php file located in your code folder. Replace XXXXX with the ID of your container which you can get from the Tag Manager interface. It takes the format GTM-XXXXX, however you don't need to include the GTM part. +All classes can be referenced via: -```php -class Page_Controller extends ContentController { +CyberDuck\GTM - public function TagManager() - { - return GTM::snippet('XXXXX'); - } -} +e.g CyberDuck\GTM\GTM::snippet(); + +## Configuring your container ID + +Add the following method to the Page_Controller in your Page.php file located in your code folder. Replace XXXXX with the ID of your container which you can get from the Tag Manager interface. It takes the format GTM-XXXXX, however you don't need to include the GTM part. + +```yml +CyberDuck\GTM\GTM + container_id: 123456 ``` -Within your Page.ss template or similar add the $TagManager variable after your opening body tag to call your controller method. +Within your Page.ss template or similar add the $TagManager variable after your opening body tag to call the GTM snippet code. ```php