arillo/silverstripe-googleanalytics
Adds google analytics tracking script to your site, if it is in production (live) mode., (*1)
Requirements
SilverStripe ^4.0, (*2)
For a SilverStripe 3.x compatible version of this module, please see the 1.x branch, or 0.x release line., (*3)
Setup
Google analytics
To make it work, you have to define AO_GA_TRACKING_CODE environment variable., (*4)
# define in .env
AO_GA_TRACKING_CODE="<YOUR_GA_TRACKING_CODE>"
Add the following into the <head> section of your template:, (*5)
$GoogleAnalytics
Google analytics 4
To make it work, you have to define AO_GA4_TRACKING_CODE environment variable., (*6)
# define in .env
AO_GA_TRACKING_CODE="<AO_GA4_TRACKING_CODE>"
Add the following into the <head> section of your template:, (*7)
$GA4
Customize
You can overwrite GoogleAnalytics.ss (or GA4.ss) on project basis, if you need some different behaviour., (*8)
Google tag manager
To make it work, you have to define AO_GTM_CODE environment variable., (*9)
# define in .env
AO_GTM_CODE="<YOUR_GTM_CODE>"
Add the following into the <head> section of your template:, (*10)
$GoogleTagManager(head)
After the opening <body> tag:, (*11)
$GoogleTagManager(body)
Customize
You can overwrite GoogleTagManager.ss on project basis, if you need some different behaviour., (*12)
Changelog
1.0.0, (*13)
1.0.1, (*14)
1.0.2, (*15)