Skip to content

How to integrate Hyrax's Google Analytics user stats into your Rails app

Michael J. Giarlo edited this page May 10, 2017 · 4 revisions

THIS DOCUMENT IS DEPRECATED (BECAUSE OUTDATED AND UNTESTED ON HYRAX)

See the Hyrax Management Guide for more information on setting up Google Analytics.


Deprecated:

== Setup & Configuration

  • Run the generators $ rails g hyrax:models:usagestats $ rails g hyrax:models:cached_stats

  • Run the migrations $ rake db:migrate

  • Edit config/initializers/hyrax.rb

    • Set config.analytics = true
    • Set the config.analytic_start_date
    • Set the config.google_analytics_id to your tracking ID (The tracking ID typically looks like UA-99999999-1)
  • Edit config/analytics.yml as described in the {README}[https://github.com/projecthydra/hyrax/blob/master/README.md#analytics]

  • Run the rake task to build the cache in the user_stats table, and schedule it as a nightly background job

    • $ rake hyrax:stats:user_stats
    • Schedule a nightly job to run that rake task so that user stats will update once a day
  • Update views

    If your Rails app overrides the app/views/dashboard/_index_partials/_stats.html.erb file from Hyrax, then you may want to update it to display the user's combined file views & downloads stats.

Clone this wiki locally