Showing posts with label Track. Show all posts
Showing posts with label Track. Show all posts

Wednesday, November 14, 2007

apache mod_usertrack 使用及其问题

为apache增加mod_usertrack module,只要动态生成一个so文件在配置文件里包括进来即可,之前有写了个文章关于这个操作过程。这次又用上了。

在虚拟主机的配置里再加上以下配置,其中具体的参数含义可参考此链接:http://httpd.apache.org/docs/1.3/mod/mod_usertrack.html


CookieTracking on
CookieStyle Cookie
CookieExpires "2 weeks"
CookieDomain .foo.bar
CustomLog logs/cookie-track.log "%{cookie}n %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
CookieName FOO_BAR

重启apache即可。
这个模块在Mozilla/Firefox中工作一切正常,而且可以做第3方的Cookie跟踪。
但是在IE(仅测试了IE6和IE7)中这个Cookie工作机制却类似于phpsessionid的工作机制,关闭IE重开之后却重新生了一个Cookie,如果不关则能正常记录用户的clickstream。但是从客户端查看HttpResponse则看得出来服务器端返回来的是正常的
请求,是让IE写个2周的Cookie,不过事实IE并不这样工作。至于用作第3方Cookie跟踪就更是不行,受P3P策略限制。

Monday, April 02, 2007

click_track plugin

Quick Start

This quick start guide will get you up and running with the click_track plugin in just a few minutes.
Installing the Plugin

You would normally use the script/plugin utility that comes with Rails to install a plugin. However, that script assumes a repository layout that is different than the one used for the click_track plugin.

Therefore, you can export the plugin from its Subversion repository, check it out, or add it as a svn:externals.

svn export \
https://crookedhideout.com/svn/oss/click_track/branches/rel/0.1/ \
vendor/plugins/click_track

Once you have the click_track plugin installed in your vendor/plugins directory, you’ll want to generate the migration for the database changes:

script/generate click_track add_clicks
rake db:migrate

Tracking a Controller
For each controller you want tracked do this:

class FoobarController < ApplicationController
click_track
end

The click_track call takes the same arguments as a before_filter.

All actions called on this controller will be tracked. Views for this controller can now use click_track(..) in place of link_to(..) for tracking when an external link is followed.
How to Use the Data
Here is the table behind the Click model:

create_table :clicks do |t|
t.column :controller, :string, :null=>false
t.column :action, :string, :null=>false
t.column :param_id, :integer
t.column :ssl, :boolean, :null=>false
t.column :http_method, :string, :null=>false
t.column :remote_ip, :string, :null=>false
t.column :request_uri, :string, :null=>false
t.column :user_agent, :string
t.column :browser, :string
t.column :browser_version, :string
t.column :browser_platform,:string
t.column :created_at, :datetime, :null=>false
end

Here are some examples of how one might use the data. These are taken from the statistics page of the crookedhidout.com site.

class StatisticsController < ApplicationController
def index
@clicks = (Click.in_last(7.days) || [])[0..12]
@popular_clicks = (Click.bucket_simple_uri_in_last(7.days) || [])[0..8]
@fan_clicks = (Click.bucket_remote_ip_in_last(30.days) || [])[0..8]
@last_24_count = Click.total_in_last 24.hours
end
end

This is going to grow my database forever!
Every one in ActionController::ClickTrack.chance times (default is 10,000) the DB will be cleared of all clicks older then ActionController::ClickTrack.oldest_click (default is 90.days). You can change these values in your config/environment.rb file. For example:

ActionController::ClickTrack.chance = 50000
ActionController::ClickTrack.oldest_click = 40.weeks