https://github.com/arillo/silverstripe-googleanalytics
https://github.com/arillo/silverstripe-googleanalytics
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/arillo/silverstripe-googleanalytics
- Owner: arillo
- Created: 2018-07-20T13:26:46.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-25T09:11:27.000Z (over 2 years ago)
- Last Synced: 2024-04-28T19:45:21.792Z (about 2 years ago)
- Language: Scheme
- Size: 8.79 KB
- Stars: 0
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# arillo/silverstripe-googleanalytics
Adds google analytics tracking script to your site, if it is in production (live) mode.
## Requirements
SilverStripe ^4.0
For a SilverStripe 3.x compatible version of this module, please see the [1.x branch, or 0.x release line](https://github.com/arillo/silverstripe-googleanalytics/tree/1.x).
## Setup
### Google analytics
To make it work, you have to define `AO_GA_TRACKING_CODE` environment variable.
```
# define in .env
AO_GA_TRACKING_CODE=""
```
Add the following into the `` section of your template:
```
$GoogleAnalytics
```
### Google analytics 4
To make it work, you have to define `AO_GA4_TRACKING_CODE` environment variable.
```
# define in .env
AO_GA_TRACKING_CODE=""
```
Add the following into the `` section of your template:
```
$GA4
```
#### Customize
You can overwrite `GoogleAnalytics.ss` (or `GA4.ss`) on project basis, if you need some different behaviour.
### Google tag manager
To make it work, you have to define `AO_GTM_CODE` environment variable.
```
# define in .env
AO_GTM_CODE=""
```
Add the following into the `` section of your template:
```
$GoogleTagManager(head)
```
After the opening `` tag:
```
$GoogleTagManager(body)
```
#### Customize
You can overwrite `GoogleTagManager.ss` on project basis, if you need some different behaviour.
## Changelog
1.0.0
- SS4 compat
1.0.1
- added GTM
1.0.2
- added GA4