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 google/matomo analytics #602

Merged
merged 3 commits into from
Apr 4, 2018
Merged

Conversation

murny
Copy link
Contributor

@murny murny commented Apr 4, 2018

#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

@murny murny changed the title WIP: Add google/momato analytics WIP: Add google/matomo analytics Apr 4, 2018
@@ -0,0 +1,7 @@
$(document).on('turbolinks:load', function() {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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'] %>
Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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 %>', {
Copy link
Contributor Author

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?

@murny murny changed the title WIP: Add google/matomo analytics Add google/matomo analytics Apr 4, 2018
Copy link
Contributor

@mbarnett mbarnett left a comment

Choose a reason for hiding this comment

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

Looks good

@mbarnett mbarnett merged commit e325996 into ualbertalib:master Apr 4, 2018
@murny murny deleted the ga/piwik-analytics branch June 21, 2018 03:21
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.

3 participants