Koha How-To
Setting up Google Analytics with Koha
Google Analytics account
1. A Google Analytics account will need to be created.
2. Once this account has been created, log into the Google Analytics account and set up a property. In Google Analytics, properties are where you send data and set up reporting views. To set up a property, go to Admin.
3 Here is a link the to the steps set up in Google for this process.
4. Once your property is created, (final step in this process is "Get Tracking ID), you must set up the tracking code to collect data. Creating a property generates a tracking ID, which you'll use in your gtag.js tracking code snippet.
5. The key piece of information that Koha needs is the Tracking ID that Google Analytics will provide. Here is a link to access that Tracking ID.
System Preferences set up
This is the code will need to be added to your system preference : opacuserjs
//Begin Google Analytics script
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'trackID', 'auto');
ga('send', 'pageview');
//End Google Analytics script
6. Replace the word <trackID> from the first ga line with the trackID that you received.
For example if your trackID was 6786763
ga('create', '6786763', 'auto');
Below is an example of what this will look like in your Koha Admin System Preference: opacuserJS
For more helpful tutorials - please see our Koha How-To section.
Read more by Kelly McElligott