Results 1 to 6 of 6

Thread: What is the best way to track hits?

  1. #1
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default What is the best way to track hits?

    I have built a site that lists all members that belong to a certain category when the viewer chooses a category from the category list. They can then click on a particular member to go to their particular page.

    I would like to keep track of how many times people go to each member's page. I know there is a way to tell if someone clicks on a link because emal marketers do it, but I'm not sure how. Any help would be appreciated. Thanks.

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Are you just looking for a simple number of how many times a page is viewed, or how many times each user visits a page in a set time frame?

  3. #3
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    The former. I just want to monitor which links are most popular and how many people my site is sending to member sites. It doesn't matter who is clicking on them or when, just an accumulative total.

    I figure that every time there is a click I run an update command such as:

    UPDATE members SET hits = (hits+1) WHERE member_id = $member_id;

    but how do you tell when there is a click? Do I do something with the <a href..> that lets me know? Thanks.

  4. #4
    Join Date
    Jul 2009
    Location
    Binus University
    Posts
    472
    Thanks
    78
    Thanked 21 Times in 21 Posts

    Default

    This snippet counts the number of hits a website receives, using flat files.
    Code:
    <?php
    <?php
    //
    // Make a blank file called count.txt and CHMOD it 777
    //
    //Lets open the file as read only (r)
    $fp = fopen("count.txt","r"); 
    // The next line reads our file into a string, 
    // in other words sets the contents of count.txt as $count,
    // so we can do stuff with it
    $count = fread ($fp, filesize ("count.txt"));
    // We don't need more data from the file right now, so close it
    fclose($fp);
    // Now we need to increment the number in the file, using the ++ operator, +1 would work but this is nicer.
    $count++;
    // Now we've incremented the count, lets write it to the file
    // We need to open if for writing (w)
    $fp = fopen("count.txt","w");
    // Now write the actual data
    fwrite($fp, $count);
    // And close the file
    fclose($fp);
    // Lets display the updated count to the users
    echo "Hits : $count";
    ?>
    ?>
    i got it from another site (thx to the author).

    Just want to share, i hope this will help

  5. The Following User Says Thank You to davelf For This Useful Post:

    kuau (08-12-2009)

  6. #5
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    Dear Davelf: Thanks, that's a very useful script which I can use elsewhere. The question above is a little different because I'm not counting how many hits on the website - maybe I used the wrong word - but rather the number of clicks on a link within the website and loading it into a database. So there will be a different total for each member's link. I hope that makes it somewhat clearer.

  7. #6
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Well, I'd make a data source, recording IPs from the amount of clicks on that page. Every person has a unique IP address, so get the total number of remote addresses, and that would be the total number of the counter.
    - Josh

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •