Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Use Google Analytics for Rails App Performance Monitoring.
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Garelic: Google Analytics Reports as "New Relic"-like performance monitoring for your Rails app

This gem uses Google Analytics User Timing API to report application performance statistics directly to Google Analytics, where you can slice & dice your data as you wish.

Here are some features with pictures:

This is a proof of concept and will probably break things. Use it at your own risk.


It's easy as 1-2-3.

Step 1. Add this line to your application's Gemfile:

gem 'garelic'

Step 2. Add <%= Garelic::Timing %> instrumentation to your GA code in application layout template like this:

<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
    _gaq.push(['_setSiteSpeedSampleRate', 100]);

    <%= Garelic::Timing %>

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

Step 3. Go to Google Analytics > Content > Site speed > User Timings


Know advantages

  • it's free
  • shows slow performing pages (not only actions)
  • show response times histogram for any action (response time averages tend to lie, since distribution of response times is multimodal)
  • segment/slice/dice response data across any dimensions available in your GA account

Known drawbacks

  • you can only track actions that return a response body (redirects, ajax-requests & async jobs are not supported)
  • all timings are visible in page source code (if you are concerned about this look elsewere)
  • caching GA code (e.g. page caching) & not modified response will probably break/skew reported statistics
  • adding user timing table widgets to GA dashboards does not preserve sorting order (wtf?)
  • it's kind of a hack


  • add more fine-grained ActiveRecord instrumentation
  • add support for adding custom user tracers (e.g. for external services)


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.