Skip to content

Google Analytics

Carrie Wright edited this page Nov 1, 2021 · 12 revisions

If you would like to add Google Analytics to track traffic to your course, you can do the following:

  1. Get a Google Analytics account (if you do not already have one): https://analytics.google.com/analytics
  2. Go to the Admin tab (lower left button that looks like a gear if you already have an account or navigated away from where you started)
  3. Set up a new property (fill out name and details, select options about tracking traffic for how you intend to use Google Analytics)
  4. Add a stream to your property, choose the Web option.
  5. Fill in your stream information with the link for your course (note you may need to remove https as this is part of a pull down menu to the left of where you paste your link)
  6. On the resulting page you will see a Measurement ID. Copy this ID and paste it in the GA_Script.Rhtml file in the template replacing the fields that say {MeasurementID} including the curly brackets.
  7. Modify the _output.yml file so that the line that starts with before body: is changed to include brackets around the GA_script.Rhtml file before a comma and the name of the hero image html file (which should already be listed). For example, like this: before_body: [GA_Script.Rhtml, assets/big-image-itcr.html] or this: before_body: [GA_Script.Rhtml, assets/big-image.html]
  8. Rerender your course by making a change to one of your chapter RMD files. The Google Analytics code should now be on each html version of your chapters in the docs directory after you push and merge on GitHub.
  9. Go back to Google Analytics. Check on the Reports button on the top of the far left icon menu. The icon looks like a bar chart. If you open up a browser window to your hosted course online, then you should see yourself as 1 user in the last 30 minutes.
  10. Enjoy the data about how people are using your course!
Clone this wiki locally