Hello Monks
I'm looking for any advise on doing something which is pretty much impossible to guarantee (and also a subject that has been beaten to death, so sorry for bring it up again).
We have a custom "forums type" application where we want to try to track the truly unique page views per person/machine as we plan to give incentives to those that are the most popular/most viewed.
Right now I'm planning on starting with just IP's and cookies (will probably be looking at flash shared objects soon).
I'm interested in anyone's opinions on a better approach then what I'm currently doing and also if anyone has any ideas on how to best deal with cookie size.
The plan so far is this
1. Have a table created that stores a page view, the table will have the message id, IP address, date viewed and a user id (if the person is logged in).
for example:
Then when viewing a page I would start withcreate table Views ( id int(11), UserId int(11), IPAddress varchar(15), DateAdded timestamp default current_timestamp )
From there the plan would beif ($session_data->{'LoggedIn'}) { $existing_view = $db->selectall_arrayref(qq|Select DateAdded from +Views where Id = ? and (IPAddress = ? or UserId = ?)|,undef,($id,$r-> +connection->remote_ip,$userid)); } else { $existing_view = $db->selectall_arrayref(qq|Select DateAdded from +Views where Id = ? and IPAddress = ?|,undef,($id,$r->connection->remo +te_ip)); }
That is about it, I know this code isn't copy/paste/run but its more to explain the flow then test anything. Like I said, I'd like to hear if anyone has any issues to the approach and/or if anyone has any comments on the cookie.unless (@$existing_view) { # get our cookie of id's if ($cookie) { unless ( grep { $_ == $id } @cookieids ) { if ($user_session_data->{'LoggedIn'} == 1) { $db->do(qq|Insert into Views (thread_id,IPAddress,UserId) values ( +?,?,?)|,undef,($id,$r->connection->remote_ip,$userid)); } else { $db->do(qq|Insert into Views (thread_id,IPAddress) values (?,?)|,u +ndef,($id,$r->connection->remote_ip)); } $cookie = $existing_cookie . $new_cookie; } else { $cookie = $id; } # set the new cookie
Right now what bothers me most about the above is there is no real limit to the size of the cookie as it could kept getting added to forever, which means at some point it will be too big.
TIA for any help!
In reply to Another page view tracking question by Analog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |