OTTR Google Analytics
Integration with your repository
Go to analytics.google.com/analytics and click Start measuring
Create or sign in to your Google Analytics account
Create a new Property — fill in a name and details
Accept the terms of service for your country / region
Click Add a Data Stream → choose Web
Enter your course URL — select
https:// from the dropdown; do not type it in the URL
field
Click Create and continue
Copy the code chunk provided on the resulting page — it will look like:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
Open GA_Script.html in your
repo
Replace the entire file contents with the code chunk you copied
Confirm _output.yml includes
in_header: GA_Script.html (already set in updated
templates)
Commit and push your changes
Open GA_Script.html in your
repo
Replace the entire file contents with the code chunk you copied
Confirm _quarto.yml includes
include-in-header: GA_Script.html under
format: html: (already set in updated templates)
Commit and push your changes
Push your changes — the GitHub Action should
trigger automatically when GA_Script.html is updated
If using an older template, manually trigger
the render_all workflow from the Actions
tab in GitHub
Open any rendered HTML file in
docs/ and search for Google Analytics to
confirm the tag was included
Log in to Google Analytics
Click the gear icon (lower left) → Data Collection and Modification → Data Streams
Click your stream and confirm traffic has been received
Click Test on the stream page, then open your live course URL and check that you appear as a visitor in Google Analytics
Click the Home button — it should say “Data collection is active”
Check the Reports tab (bar chart icon, upper left) — opening your course in a browser should show you as 1 user in the last 30 minutes
| Issue | What to Check |
|---|---|
| No data showing in GA | Make sure the code chunk in
GA_Script.html was copied correctly and contains the right
ID (G-XXXXXXXXXX) |
| Data stream shows no traffic | Check that the URL in the stream matches your
course URL — watch for https vs http |
| Old template not rendering GA | Manually run the render_all workflow; confirm both
_output.yml and GA_Script.html are updated and
filenames are consistent |
| Render not triggering | Ensure GH_PAT is set up for the repo (with
actions and repo permissions), not just the
organization |