This is a no-brainer. Google Analytics is a easy-to-use, robust engine that offers not only social media campaigns management, but also tons of other exciting features.
Since it’s such a no-brainer though, I’m not going to go too much into showing you how to set it up or make it work, since most people who ‘make the web’ have already done that at this point. If not, there is a myriad of guides and tutorials out there. Google it!
I will, however, show a neat way of tracking visits from different media for those out there who are afraid of Google snooping around their website.
If your data is so sensitive that you want to keep it as private as possible, you can store it inside your rails application thanks to the Ahoy gem.
As with all rails gems, basic installation is easy:
It works on most popular data stores, including:
rails generate ahoy:stores:active_record -d postgresql rake db:migrate
MySQL and SQLite
gem 'activeuuid', '>= 0.5.0'
rails generate ahoy:stores:mongoid
If you don’t need to store those things in a databse, you can always use a log file:
rails generate ahoy:stores:log
The gem automatically saves vital information about the visit: the source, location, browser used, and all the tm parameters that come with the visit – you can access all of these with the current_visit helper (useful if you want to set the locale depending on where the user is). With Devise, the visit is automatically assigned to the user on login/register.
Additionaly, you can track Events – to see the user’s journey through your site.
All in all, it’s a very solid alternative to Google that you can set up internally in your app – keep in mind though, that the more traffic your site will have, the more data you will store locally. To deal with that, I recommend reading This post by Jan Czuma.