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

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('create', trackID, 'auto');
ga('send', 'pageview');

let trackID = "";

//End Google Analytics script

6. Copy and paste the trackID into the line right above "End Google Analytic script" between the double quotes : let ID = ""

For example

let ID ="6786763"

This will populate the trackID into the code for you!

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

Tags OPAC, google, opacuserjs