Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for configurable analytics #586

Merged
merged 3 commits into from
May 28, 2024
Merged

Add support for configurable analytics #586

merged 3 commits into from
May 28, 2024

Conversation

froggleston
Copy link
Contributor

This PR aims to implement configurable analytics to address #438 with a new config.yaml option, analytics.

Options:

  • Default option for analytics is NULL, or not supplying it, and therefore disables tracking for that lesson
  • analytics: carpentries will add the Carpentries matomo tracking script to the footer.html (see corresponding varnish PR)
  • analytics: | <user_string> will add the user supplied tracker script string, e.g. for google analytics:
analytics: |
  <!-- Global site tag (gtag.js) - Google Analytics -->
  <script async src='https://www.googletagmanager.com/gtag/js?id={YOUR TRACKING ID}#' ></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

    gtag('config', '{YOUR TRACKING ID}');
  </script>

Copy link
Member

@tobyhodges tobyhodges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested and can confirm that this works. Thanks @froggleston 🙌

It would be good to polish this to improve security in future, but I have not yet been able to work out a way to allow for different Matomo configurations without providing a free text field like this. I think we should merge and put security improvements on the list of things it would be nice to do in the future.

@froggleston
Copy link
Contributor Author

Thanks @tobyhodges ! I agree. The addition of user-specified tracking code would hopefully be fairly transparent, as tracking code would be committed alongside any lesson. I think that at least having the option to include or exclude Matomo tracking would make this PR worth it.

@froggleston froggleston merged commit fbae51c into main May 28, 2024
12 checks passed
@froggleston froggleston deleted the analytics branch May 28, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants