Page 1 of 3 123 Last
  • Jump to page:
    #1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Nobbies beach, Gold Coast. It's beautiful.
    Posts
    2,575
    Rep Power
    171

    Count number of times page has been loaded by human users, not robots


    Of course Google "anal" is the best.

    But if I want to have a small update code that I can see how many times page has been loaded by real users.:
    PHP Code:
    $sql  "UPDATE page_loads SET load_count = load_count +1 WHERE id = 2";
    $execute($sql); //Something like this 
    If I put this on to of my page it might be ran by robots too. So instead of 20 users I get 200 loads.

    So how can count only real users?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    194
    Rep Power
    76
    You can't, there is no real conceivable way to tell between a bot and a real human even if you use javascript to do this
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,868
    Rep Power
    368
    your user stats or google analytics will tell you exactly where the last set of users for the x date or in a range, came from
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    667
    Rep Power
    6
    Couldn't you do this with some kind of browser check? Like would a bot define itself as using IE, Firefox, ...?
    He who knows not and knows not he knows not: he is a fool - shun him. He who knows not and knows he knows not: he is simple - teach him. He who knows and knows not he knows: he is asleep - wake him. He who knows and knows he knows: he is wise - follow him
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,692
    Rep Power
    6351
    The combination of the answers in this thread gives you the real answer: YOU can't, Google can (usually). Google analytics is amazing, just go ahead and use that.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,803
    Rep Power
    529
    I "thought" most robots do render JavaScript. If this is the case, you could use Ajax to send a POST to update your counter.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    194
    Rep Power
    76
    Originally Posted by NotionCommotion
    I "thought" most robots do render JavaScript. If this is the case, you could use Ajax to send a POST to update your counter.
    how would that help? the bot would still be adding up to the counter, the OP wants it so only real human viewers would update the counter and not bots

    and most bots do render javascript, only the very old bots or specifically designed ones would not run javascript
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,803
    Rep Power
    529
    Originally Posted by jack13580
    how would that help? the bot would still be adding up to the counter, the OP wants it so only real human viewers would update the counter and not bots
    I meant to say no not render JS. If that was the case (which it evidently no longer is), one could conclude that the number of times the site was accessed by a JS enabled browser is the number of humans.
  16. #9
  17. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,692
    Rep Power
    6351
    Bots that can't crawl facebook, gawker, and twitter aren't really all that useful anymore, are they? All modern search engines process javascript.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  18. #10
  19. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Nobbies beach, Gold Coast. It's beautiful.
    Posts
    2,575
    Rep Power
    171
    Dan, what's the final verdict?
  20. #11
  21. Amateur Webdev'er
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    141
    Rep Power
    11
    Been using this for a couple years, and my stats for some pages are still ballooned.

    PHP Code:

                
    if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "spider") ||
                    
    strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "crawl")  ||
                     
    strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "bot"))
              
                   
    $agent_pass FALSE
    There's really now way of programming your way around it. Awstats treats me well, but this is what I have to do for hits on single pages. Any decent analytics software will do much better. The only reason I haven't switched to GA is because it's not mission critical.
    Last edited by xpatriot; February 1st, 2014 at 02:13 PM.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,232
    Rep Power
    593
    I wouldn't do either. I would not use $GLOBALS for my connection. I always create a singleton connection class and if I need that in different scripts, I would use includes. Then instantiate that class in each script.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  24. #13
  25. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,692
    Rep Power
    6351
    Originally Posted by English Breakfast Tea
    Dan, what's the final verdict?
    Google analytics is what I would use. my company doesn't keep stats this way though, it's a private portal.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  26. #14
  27. Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Location
    New Springfield, OH
    Posts
    1,181
    Rep Power
    1469
    Originally Posted by ManiacDan
    The combination of the answers in this thread gives you the real answer: YOU can't, Google can (usually). Google analytics is amazing, just go ahead and use that.
    Well, you can do the same thing Google does and implement browser sniffing. There are tons of libraries out there for it.

    That being said, I agree with your answer though. Why reinvent the wheel? Google Analytics does a fantastic job of hashing out a lot of different metrics and it takes about 2 minutes to implement (and that includes creating an account).
    Don't like me? Click it.

    Scripting problems? Windows questions? Ask the Windows Guru!

    Stay up to date with all of my latest content. Follow me on Twitter!

    Help us help you! Post your exact error message with these easy tips!
  28. #15
  29. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Nobbies beach, Gold Coast. It's beautiful.
    Posts
    2,575
    Rep Power
    171
    Hi;

    I need to find out conversions. You know? How many of people who see "sign up form" actually sign up.

    I could easily set it up if I could reply on page loads (by human only).

    But a bit harder with Google Anal.
Page 1 of 3 123 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo