PDA

View Full Version : counting active session by eliminating bot


neontwenty
11-13-2010, 06:01 AM
hi friends

how to count active session.
i have read few post that explains about incrementing an
application variable on session start and decrement it on session end

Sub Session_OnStart
Application.Lock
Application("total_visitors_atpresent")=Application("total_visitors_atpresent")+1
Application.UnLock
End Sub

Sub Session_OnEnd
Application.Lock
Application("total_visitors_atpresent")=Application("total_visitors_atpresent")-1
Application.UnLock
End Sub


but what if the google/yahoo/bing bot visit the site.

the same thing happen and i should think of checking the HTTP_USER_AGENT
and do the increment accordingly.

then problem is how to i decrement while the session end. can we check
which session is ended. like is the bot session or is it the actual visitors session that ends. how do you do this?

thanks

Old Pedant
11-13-2010, 09:19 PM
Keep two counts:

total_visitors = real visitors plus bots
bot_visitors = bots only

When you display the number, just display (total_visitors - bot_visitors).

It won't be perfectly accurate, but Application_OnEnd is so flaky and inaccurate that it should be good enough.

neontwenty
11-14-2010, 05:23 AM
old pedant,

the problem is when i do the decrement.

consider i have

application("total_visitors")=10 '//(7 real + 3 bot)
application("bot_visitors")=3 '//(3 bots)

Sub Session_OnEnd
application("tota_visitors")=application("tota_visitors")-1
End Sub

what if 2 session ends from bot visitors, i should disply
8-3=5 '//not correct, i should have 7 real visitors

what if 2 session ends from real visitors and 1 session ends from bot
7-3=4 '//not correct, i should 5 real visitors

it can be done easily if i can identify which session is ending

how do you distinguish which session is end (bot or real)?

thank you

Old Pedant
11-15-2010, 04:34 AM
Are you aware of how inaccurate Application_OnEnd is????

A user might leave your site 10 seconds after visiting it, and yet it will take 20 minutes for the session to disappear and invoke OnEnd.

Honest, you can *NOT* get an accurate count of "visitors on my site" in this way. You have to create your own mechanism if you want better accuracy.

So if you are ready to create your own complete mechnanism for tracking visitors, then you can easily weed out the bots. But if you aren't, then doing as I suggested is surely as accurate as you really need.