Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app Add an index on user agents table, on the md5 hash of the user agent.…
config
db/migrate
lib Add an index on user agents table, on the md5 hash of the user agent.…
spec
.gitignore
Gemfile
HISTORY
LICENSE
README.md
Rakefile
config.ru
notches.gemspec

README.md

Notches

A Rails Engine for tracking your web traffic.

Installation

Add this to your Gemfile and run the bundle command.

gem 'notches', '~> 0.1.0'

And then install and run the necessary migrations.

rake notches:install:migrations
rake db:migrate

Mount your engine at your desired location in config/routes.rb.

mount Notches::Engine => '/notches'

Finally to start recording hits include the notch pixel image at the bottom of your views.

<%= image_tag "/notches/hits/new.gif?url=#{request.url}" %>

Counting hits

For a URL:

Notches::Hit.joins(:url).where('url like ?', '/posts').count

For an IP:

Notches::Hit.joins(:ip).where('ip = ?', '127.0.0.1').count

For a session id:

Notches::Hit.joins(:session).where('session_id = ?', 'abcd').count

For a date:

Notches::Hit.joins(:date).where('date = ?', Date.today).count

For a particular time of day:

Notches::Hit.joins(:time).where('time between ?', '09:00:00', '17:00:00').count

Or a user agent:

Notches::Hit.joins(:user_agent).where('user_agent like ?', '%Mobile%').count

To get a better idea of how Notches is setup check out the Notches::Hit model.

Something went wrong with that request. Please try again.