how to keep track of how many people visit a site

how can you keep track of how many different people go to your site?

Page 1 of 1

6 Replies - 3406 Views - Last Post: 25 February 2010 - 09:37 AM

#1 OMNICIDE666  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 22
  • Joined: 09-November 09

how to keep track of how many people visit a site

Posted 24 February 2010 - 07:17 PM

here's an example of what i'd like to know (please note there is some material on site that may be inappropiate for children under 18) it's not the content on the page that i want, but the code behind it:

http://www.ihatenikk...nk=or04or06or03

it's almost like a hit counter. saying xx number of people have went to this site, but it somehow know if it's you that visits the site and therefore does not up the count when you go to it. this is what i want! i'm making my own site (non porn related in case u were wondering) and would like a thing on there that can do that too. also, how can u "unlock" things on the site depending on how many views the site has got like the above site does?? anything else you'd like to know about what i'm trying to do, please feel free to ask me!! k thanks soo much for your help!!

Is This A Good Question/Topic? 0
  • +

Replies To: how to keep track of how many people visit a site

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1137
  • View blog
  • Posts: 7,099
  • Joined: 07-September 06

Re: how to keep track of how many people visit a site

Posted 24 February 2010 - 10:56 PM

That is likely done by having a PHP (or other server side langauge) add each page hit to a database (timestamp and IP address), then count all the page hits that have been added to the database with a query like so:
SELECT COUNT(ip) FROM `pageHits` GROUP BY `ip`

which basically says count all the IPs returned from the pageHits table where we remove all duplicate IP addresses from.

Hopefully that makes sense.
Was This Post Helpful? 1
  • +
  • -

#3 OMNICIDE666  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 22
  • Joined: 09-November 09

Re: how to keep track of how many people visit a site

Posted 24 February 2010 - 11:20 PM

ok great but how or what is the code i would put on my site, im new to web development and need to be helped through step by step if you don't mind. thanks!
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1137
  • View blog
  • Posts: 7,099
  • Joined: 07-September 06

Re: how to keep track of how many people visit a site

Posted 24 February 2010 - 11:41 PM

Okay, I guess the first question will be if your site allows for PHP and MySQL? If it doesn't you will not be able to do this without finding some service that provides it for you.

If it does you will need to create a database and then a table within that database that has 2 columns. One for the timestamp, and the other for the IP address.

Once you have the database set up you will need to create a connection to it from PHP:
http://us2.php.net/m...sql-connect.php

Get the user's IP address:
$userIP = $_SERVER['REMOTE_ADDR']);


Get the current timestamp:
$time = strtotime("now");

You could also just use MySQL's timestamp stuff, but I have always preffered using PHP's.

Construct a query:
$query = "INSERT INTO `tableName`(`timestamp`, `ip`) VALUES('" . $time . "', '" . $userIP . "')";


Do the query:
mysql_query($query, $link);


This should have successfully added the information to the database. Now we want to access stuff from it.

For the query here you will use what I said up above, then go through and query the same general way as the last code I gave. From there you will have to fetch the associated results:
http://us.php.net/ma...fetch-assoc.php

Sorry, I know it really is kind'a all over the place, but it is late and I need some sleep. You may wish to look at more of the PHP functionality (at php.net) and the tutorials we have here at DIC: http://www.dreaminco...showforum47.htm

Hopefully that helps.
Was This Post Helpful? 1
  • +
  • -

#5 OMNICIDE666  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 22
  • Joined: 09-November 09

Re: how to keep track of how many people visit a site

Posted 25 February 2010 - 12:45 AM

lol im really sorry but ur gonna have to explain what u just said, i like literally started web making like 2 days ago and have no idea what im doing. im trying to teach myself this... its not immediate that i know this so if ur busy then take your time k? thanks for the help so far though :)
Was This Post Helpful? 0
  • +
  • -

#6 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1359
  • View blog
  • Posts: 3,424
  • Joined: 28-November 09

Re: how to keep track of how many people visit a site

Posted 25 February 2010 - 09:21 AM

Just google free online hit counter.
Was This Post Helpful? 0
  • +
  • -

#7 OMNICIDE666  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 22
  • Joined: 09-November 09

Re: how to keep track of how many people visit a site

Posted 25 February 2010 - 09:37 AM

View PostLemur, on 25 February 2010 - 08:21 AM, said:

Just google free online hit counter.


no i need the actual code for what i'm trying to do to work. and i already did look it up anyway, the code is just links to their sites so i can't see the actual code that gathers the ip and keeps track of them...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1