forked from ottrproject/ottr_documentation_dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmore_features_ganalytic.qmd
More file actions
51 lines (33 loc) · 3.09 KB
/
more_features_ganalytic.qmd
File metadata and controls
51 lines (33 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
title: "More Features: Google Analytics Integration"
output:
html_document
---
## Google Analytics
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](https://analytics.google.com/analytics)

Note that in creating an account you will need to agree to some terms. Currently it is free to get Google analytics data as long as your course does not exceed a very high user rate.
Check to make sure that the terms work for you

1. If you already have an account or navigated away from where you started - Go to the **Admin tab** (lower left button that looks like a gear)
1. Set up a new **property** (fill out name and details, select options about tracking traffic for how you intend to use Google Analytics)



1. Add a **stream** to your property, choose the **Web** option.

1. 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)


1. On the resulting page you will see a **Measurement ID**. Copy this ID and paste it in the GA_Script.html file in the template replacing the fields that say {MeasurementID} including the curly brackets. For example, if your ID was `G-ABC123`, then the line `gtag('config', '{MeasurementID}');` would become `gtag('config', 'G-ABC123');`.


1. Add a line to the _output.yml file above the line that starts with `before body:` (i.e. nested under `includes`). This line should be `in_header: GA_Script.html`. Make sure this line is indented to the same level as the `before body:` line.

1. **Rerender** your course by making a change to one of your chapter RMD files in a pull request and pushing and merging the pull request. This will cause new html files to be made for each chapter in the `docs` folder. The Google Analytics code should now be in each of the html files - you can check by searching for `Google Analytics`.
1. Go back to [Google Analytics](https://analytics.google.com/analytics) and log in if you need to.
1. 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.


1. Enjoy the data about how people are using your course!