It is possible to install Google Analytics tracking on your Pressbooks-hosted network.
To do so, you will need to create a Google Analytics property, then add it to your network.
Once the tracking code is added, you will be able to configure views and reports inside Google Analytics.
Creating a Google Analytics Property
In order to use Google Analytics (“GA”), you will need a GA account, and a property for your Pressbooks network inside your GA account.
If you need help getting set up, please consult the Google documentation on setting up a GA account and property.
Once your Pressbooks property has been created, copy your GA tracking code (looks like “UA-123456789-0”) and add it to your network by following these steps:
- Go to your Network Admin dashboard
- Go to Settings > Google Analytics from the left sidebar menu
- Paste in your Google Analytics code in the field labeled Google Analytics ID
- Decide whether or not to enable site-specific tracking
- Save your changes
You will start receiving data in Google Analytics as soon as the code is added to your network.
Configuring Google Analytics for Pressbooks
By default, all analytics data will be sent to the “All Web Site Data” view, and include data for all frontend and backend (admin) pages. This means the data for all the books on your network will be collected in the same place.
The default setup should cover most use cases for network managers and require no additional configuration.
In some cases, network managers may want to give individual book authors direct access to the analytics data. This can be done in different ways, such as through filtered views or custom reports.
To help you configure your GA, we provide instructions below. However, please note that we cannot offer more in-depth support for Google Analytics.
Filtered views allows you to access the default GA reporting interface, but with a subset of the data.
For more information on Views, please read the Google documentation.
To create a filter for a specific book on your Pressbooks network, configure the filter as follows:
- Filter name: insert the name you want to give to your filter, for example the book title.
- Filter type: select: Predefined. In the drop-down lists below, select: Include only, traffic to the subdirectories, that contain.
- Subdirectory: insert the subdirectory of the book. The subdirectory can be seen in the book’s URL, right after the main domain (ex: https://university.pressbooks.pub/booktitle/). Do include the slashes (‘/’) at the beginning and the end.
Below is an example of a configured book filter:
Once the view has been created, you can give other users access to it. For help, please read the Google documentation on user management.
Google Analytics comes with a number of built-in reports that cover most use cases.
For more information on the default reports in GA, check out the Google documentation on:
If you need to track specific metrics at regular intervals, it may be useful to create custom reports, and set up automatic emails to have them sent at regular intervals.
- Google documentation on creating custom reports
- Google documentation on Exporting and Sharing Reports (for automated emails, see the Share a report section)
Automatic emails can also be set up for any of GA’s default reports.