Jump to content

Highly Efficient Unique Visitor Script


Jordban

Recommended Posts

Hello,

 

I know of many solutions to the classic unique vistors script.

 

My question is: Which is most efficient?

 

I want to do unique visitors per page per day.

 

Should I just place all the data in one table with the columns (id,ip, page).

 

User visits page:

Checks if there is a match to ip / page.

 

If no match insert into db ip / page and update unique visitors.

 

Recreate table every night.

(I realize this isn't a "true" 24 hour visitor check, but It's more efficient)

 

Problem I would think with this is if you have 10,000 users visit your site in a day you would have 10,000 of rows in the mysql que.

 

Can anyone think of a method that would be more efficient then this? Possibly not using MySQL?

 

Thanks!

 

EDIT: Please keep this here, I'm not sure if MySQL is the best solution or not.

 

Link to comment
Share on other sites

One (very much not foolproof) method would be to store a cookie on the visitor's machine, then everytime someone visits, add one to a field (probably a text file, for speed) if they don't have the cookie, and set the cookie.

 

Most people tend to have cookies enabled, so it's fairly good, but nowhere near foolproof.

Link to comment
Share on other sites

One (very much not foolproof) method would be to store a cookie on the visitor's machine, then everytime someone visits, add one to a field (probably a text file, for speed) if they don't have the cookie, and set the cookie.

 

Most people tend to have cookies enabled, so it's fairly good, but nowhere near foolproof.

 

Thanks for taking the time to reply!

 

I don't want to use this solution because deleting your cookies or changing browsers is way too easy. I would like to at least make users use a proxy. The unique visits count is actually significant in this situation.

Link to comment
Share on other sites

Fair enough, I just thought of that as an alternative to storing several thousand fields in a database.

 

Make sure you index the IP on the sql table for searching. (Apologies if I'm teaching you to suck proverbial eggs, but better to mention to someone who knows than ignore it for someone who doesn't)

Link to comment
Share on other sites

Fair enough, I just thought of that as an alternative to storing several thousand fields in a database.

 

Make sure you index the IP on the sql table for searching. (Apologies if I'm teaching you to suck proverbial eggs, but better to mention to someone who knows than ignore it for someone who doesn't)

 

Just googled indexing, looks awesome! So congrats to us both :)

 

I just create my table like usual but add this at the end of the que.

 

,INDEX (ip)

 

I'd still love to hear some better ways of doing this.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.