0.0
No commit activity in last 3 years
No release in over 3 years
Adds a helper to create the google analytics script in rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 0.21

Runtime

~> 5.1
 Project Readme

Gem Version Code Climate Build Status Dependency Status

Analytics Rails

Adds a helper to create the google analytics script in rails.

Why

I did this gem to:

  • Have a simple but versatile way to include google analytics.

Install

Put this line in your Gemfile:

gem 'analytics-rails'

Then bundle:

$ bundle

Usage

Include tag must be added before any other tag in order to work and only will be shown in production.

Include

In your layout add a line like this in your head:

<%= google_analytics_include_tag 'UA-000000-01' %>

You can add metrics if you want:

<%= google_analytics_include_tag 'UA-000000-01', category: 'products' %>

Events

To send events add a line like this with the category and action:

<%= google_analytics_event_tag 'Video', 'play' %>

You can add label, value and other options too if you want:

<%= google_analytics_event_tag 'Video', 'play', 'demo.mp4', 42, category: 'product' %>

Contributing

Any issue, pull request, comment of any kind is more than welcome!

I will mainly ensure compatibility to Rails, AWS, PostgreSQL, Redis, Elasticsearch and FreeBSD. 

Credits

This gem is maintained and funded by mmontossi.

License

It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.