Skip to content

Commit

Permalink
update readme with YML container config info
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Mc Cormack committed Oct 26, 2017
1 parent 3cc1ba5 commit e9740c0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 14 additions & 11 deletions docs/installation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<body>
Expand Down

0 comments on commit e9740c0

Please sign in to comment.