www.SmarteGuru.com
  Home | Blogs | Recipe | Find a Friend | Discussion Board | Resources | Developers Area | Articles | Health |  Login | Register Now 

Integrate Google Analytics Plugin in your application

This plugin will automatically add Google Analytics code to all of your pages, instead of manually having to add it to app/views/application.rhtml. You put your tracker id in config/environment.rb and it Just Works. It will, by default, only work in production mode, and you can switch it off for particular controllers and actions.

To install it, add plugin repository to your rails plugin sources:

script/plugin source http://svn.rubaidh.com/plugins/trunk

and to install the Google Analytics plugin:

script/plugin install google_analytics

To configure it, add the following to config/environment.rb:

Rubaidh::GoogleAnalytics.tracker_id = 'UA-12345-67'

where the tracker_id is what _uacct gets set to in the chunk of javascript that Google gives you to insert. That’s it! All configured! Your tracking information will be inserted into every page. If you don’t want it in particular controller, you can do the usual to skip after_filters:

skip_after_filter :add_google_analytics_code

Related Posts

Tags: , , , , ,


Viewed: 80 views

Leave a Reply

Comment moderation is enabled. Your comment may take some time to appear.

Home - About Us - Help - Terms and Conditions - Site Map - Link to Us - Resources - Contact Us
Google Rank Calculator | Suggest developer resource | Suggest Article
All rights reserved © 2007 SmarteGuru.com.