OTTR Google Analytics
Integration with your repository

Download cheatsheet
Last updated: May 13, 2026


Set Up Google Analytics

Create an Account & Property

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

Add a Data Stream

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>

Configure Your OTTR Repo

For OTTR (Rmd-based) Courses

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

For OTTR Quarto Courses

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


Trigger & Verify a Re-render

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


Verify Traffic Is Being Tracked

Log in to Google Analytics

Click the gear icon (lower left) → Data Collection and ModificationData 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


Troubleshooting

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


Authors: Padmashri Saravanan from BioDataSage created the cheatsheet content. Carrie Wright reviewed the material. Kate Isaac created the original styling, Carrie Wright did the css styling and Carrie Wright and Candace Savonen did the publishing engineering for the cheatsheet.
OTTR was created and or is maintained by the following team: Candace Savonen, Carrie Wright, Kate Isaac, Ava Hoffman, Adam Coffman, Katherine Cox, Federick Tan, John Muschelli, Howard Baek, and Jeffrey Leek.