Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 config
Octocat-spinner-32 db
Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 HISTORY
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 config.ru
Octocat-spinner-32 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.