-
Notifications
You must be signed in to change notification settings - Fork 10
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 google/matomo analytics #602
Conversation
@@ -0,0 +1,7 @@ | |||
$(document).on('turbolinks:load', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Snippet is to make google analytics work with turbolinks. Since turbolinks mask real page refreshes. Code mostly taken from this gist: https://gist.github.com/esBeee/545653241530f8f2c2e16371bec56f20
}); | ||
} | ||
// Matomo Analytics | ||
if (window._paq != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda an assumption? Hardly any documentation on this, other then:
http://reed.github.io/turbolinks-compatibility/piwik.html (old resource though?)
and reading through:
https://developer.matomo.org/guides/tracking-javascript-guide
@@ -25,6 +25,9 @@ shared: | |||
ezid_default_shoulder: <%= ENV['EZID_DEFAULT_SHOULDER'] %> | |||
ezid_user: <%= ENV['EZID_USER'] %> | |||
ezid_password: <%= ENV['EZID_PASSWORD'] %> | |||
google_analytics_token: <%= ENV['GOOGLE_ANALYTICS_TOKEN'] %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Examples of these will be like the following:
GOOGLE_ANALYTICS_TOKEN='UA-XXXX1234-1'
MATOMO_URL='analytics.piwikserver.ca/piwik'
MATOMO_SITE_ID=8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/ualbertalib/jupiter/blob/master/.env_deployment_sample would be a good place to document this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Added them there
$(document).on('turbolinks:load', function() { | ||
// Google Analytics | ||
if (typeof gtag === 'function') { | ||
return gtag('config', '<%= Rails.application.secrets.google_analytics_token %>', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge fan of this, rendering erb in a javascript file. Ties the client to close to the server. Maybe a data-attr somewhere, or set a global javascript variable when I am embedding this script in the head etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#601
First crack at adding analytics (google/matomo/piwik) to jupiter.
Might have to refine this and add more options once we start seeing the data come in