0.01
No commit activity in last 3 years
No release in over 3 years
Simple way to add Google analytics, universal analytics, uservoice, etc. to your rails app
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

Gem Version

Simple way to add Google analytics, universal analytics, uservoice to your rails app

TheTracker

A Gem to help you add tracker components to your application. Instead of having to write javascript code to add this trackers you can use plain pure ruby.

Currently this components are supported:

Google Analytics

Google Universal Analytics

Google Tag Mangaer

Uservoice

Ad Form

Google Ad Services

Kenshoo Conversion Pixel

Relevant Traffic Conversion Pixel

YD RTB Pixel

Smart 4 Ads

Installation

Add this line to your application's Gemfile:

gem 'the_tracker'

And then execute:

$ bundle

Or install it yourself as:

$ gem install the_tracker

Usage

Create a file in config/initializers/tracker.rb

Add all the trackers you need

TheTracker::Tracker.config do |tmf|
  tmf.add TheTracker::Trackers::Uservoice.new('YOUR_KEY', {:forum_id => 123, :tab_label => 'Say Hi!'})
  tmf.add TheTracker::Trackers::GAnalytics.new(:id => 'UA-1234123-99')
end

In your views add

<header>
  <%= header_tracking_code.html_safe %>
</header>

If the tracker needs to add code into the body:

<body>
  <%= body_top_tracking_code.html_safe %>

  ... your page html ...

  <%= body_bottom_tracking_code.html_safe %>
</body>

And that's all, the tracking code will be added automatically

Sometimes you only want to track certain pages:

For instance, this example will show the Google Analytics code only if some_condition evaluates to true

<header>
  <% TheTracker::Tracker.instance.trackers[:ganalytics].active = some_condition %>
  <%= header_tracking_code.html_safe %>
</header>

You can add a tracking code on a single page:

TheTracker::Tracker.config do |tmf|
  tmf.add_once TheTracker::Trackers::Uservoice.new('YOUR_KEY', {:forum_id => 123, :tab_label => 'Say Hi and disappear!'})
end

For more examples please visit how to use it

Read the documentation to find details about how to implement each pixel available.

Author

Created by Jorge Alvarez

@jorgealvarez

http://www.alvareznavarro.es

I would like to thanks to the Sage One team for their support in the development of this gem

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

The Tracker is released under the MIT License.

Log

Version 1.4.1

Fixed bug where custom vars and metrics where persisted through different pages in Universal Analytics

Version 1.4.0

Smart 4 Ads support

Universal analytics require libraries for demographic reports and enhanced link attribution

Version 1.3.1

Fixed gem generation problem

Version 1.3.0

YD RTB support

Version 1.2.3

Fixed bug with namespace

Version 1.2.2

Support for more than one Universal analytics account

Version 1.2.1

Support for userId in Universal analytics

Version 1.2.0

Added Universal analytics

Version 1.1.2

Added Relevant Traffic conversion pixel support

Version 1.0.0

Everything is stable so time to bump version to 1.0.0

Added Kenshoo conversion pixel support

Version 0.5.0

Now you can add a tracker that will be displayed only once and removed from subsequent requests.

Version 0.4.6

Fixed bug that keeped information about transactions on each page load. Now transaction information is displayed only once.