An easy and basic Google Analytics extension for TYPO3.
- Install TYPO3 extension via composer, TER or download and install manually.
- Configure the extension
- Call
googleAnalyticsDisable()
orgoogleAnalyticsEnable()
via JavaScript to disable or enable Google Analytics. By default it is enabled. The user can disable tracking with a simple button which can look like this:<a onclick="return googleAnalyticsDisable();">Disbale GA Opt Tracking</a>
There are several options to add your tracking id. The following list will show you all options in the prioritized order.
- Add the tracking ID within the sys_template row via the backend module
- When you add your template through the runThroughTemplatesPostProcessing hook add the tracking ID like so:
// $row is your template record array
$row['constants'] .= 'google_analytics_tracking_id = UA-11111111-1';
- Add the tracking ID directly to the settings section inside your site configuration file:
settings:
googleAnalyticsTrackingId: UA-11111111-1
- To allow onclick events within CKEditor add
extraAllowedContent: '*(*)[onclick]'
to your CKEditor configuration file. Then you can add a link withonclick="return googleAnalyticsDisable();"