Results 1 to 7 of 7

Thread: In a PHP "Affiliate Application" how I count total unique visitors came from a url eg

  1. #1
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default In a PHP "Affiliate Application" how I count total unique visitors came from a url eg

    In a PHP "Affiliate Application" how I count total unique visitors came from a url eg.
    http://www.example.com/index.php?aid=12345 ? this url may be in many websites ...

    I must use a db table field eg countUniqueVisitors ?
    Last edited by leonidassavvides; 03-31-2009 at 06:37 PM.

  2. #2
    Join Date
    Mar 2009
    Posts
    65
    Thanks
    13
    Thanked 4 Times in 4 Posts

    Default

    There are two ways to do it.

    Method #1 - One way to do it is to give each affiliate an ID. Then basically just increment the number.


    Method #2
    However, this won't help if someone keeps on refreshing the page. You would need a log, which log every-time someone comes to the site through a particular affiliate. You will need to log the IP address (that is not 100% reliable though) and time of visit, Whenever there's a hit, do a SQL query and check the IP address -- if it has been logged before, don't log it. Or else, log it in.

    You may want an expiry date for unique visitors; if so, you may wish to specify a date range inside your SQL for detecting duplicated visitors.

    A SQL query "SELECT COUNT(*) FROM AFFILIATES_VISITORS WHERE ID = $wanted_ID" will give the unique visitors

    If you wish to prune the database, say, after 6 months, or monthly, you can have a cron job which delete all entries older than 6 months, but before that do a final tally (as in Method #1) and add it to a running total of total unique visitors.

  3. #3
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    How I get IP for a webuser in PHP ?
    When IP is the same but date of 3mo past[cookie aff], I must log it as another hit or not ?
    Last edited by leonidassavvides; 04-01-2009 at 07:47 AM.

  4. #4
    Join Date
    Mar 2009
    Location
    Florida
    Posts
    31
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default

    Quote Originally Posted by CrazyChop View Post
    Method #1 - One way to do it is to give each affiliate an ID. Then basically just increment the number.
    This won't track uniques though. This will get all hits but you need something else for uniques, like setting cookies.

    Cheers,

  5. #5
    Join Date
    Mar 2009
    Posts
    65
    Thanks
    13
    Thanked 4 Times in 4 Posts

    Default

    Quote Originally Posted by Lpe04 View Post
    This won't track uniques though. This will get all hits but you need something else for uniques, like setting cookies.

    Cheers,
    Not an expert on this subject really but IP addresses are unreliable (due to NAT) and cookies can be flushed; yep, you should check for if the user is unique before incrementing the DB, may bad.

  6. #6
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    IP Addresses has any relation with tel line ? if i change connection (tel line or network) via a laptop IP changes ?

  7. #7
    Join Date
    Mar 2009
    Posts
    65
    Thanks
    13
    Thanked 4 Times in 4 Posts

    Default

    Quote Originally Posted by leonidassavvides View Post
    IP Addresses has any relation with tel line ? if i change connection (tel line or network) via a laptop IP changes ?
    Ah no...

    IP addresses have nothing to do with phone lines and are solely abstract. They exist in 4 classes, with each classes having different number of potential addresses. The 4 classes are known as A, B, C and D. I forgot what those classes are for, but one is for education institutes and one is for commerical IP while others are reserved.

    As IP addresses were 32-bit in length, the experts assumed that there were enough to go around. However, the unexpected commercialization caused commerical IP addresses to run out. So what is done nowadays is called Network Address Translation (NAT). Each Internet rovider has an IP (a real IP) while each of its customer has a 'temporarily IP' assigned base on their own rules. Broadband users may get a IP when they log on while cable-users get one when depending on their land line.

    That user's IP however is not unique - it is entirely possible that someone else has your IP address. However, from the first three (or two) set of digits in the IP address, it is possible to determine which is your Internet provider - they will send the entire address over tot the provider, which will do some internal magic to determine to whom the IP really represents. If the IP is sent to some other provider, someone else would get the internet packets.

    What happens here is Network Address Translation. Basically, the provider/gateway tags your MAC (machine address code, based on your ethernet card) which is an unique number (throughout the world, 99.99) to a dynamically assigned IP address (which is not unique throughout the world) and send it out. When the gateway/provider received a packets, it will look up the MAC address by the IP given, find out where you are, under-go some more ethernet/LAN mumbo-gumbo (which I can't remember very well) and send the packet to you.

    Which is why, until IP 62-bit come out, tracking people base on IP doesn't work. It at most will tell you his country and his service provider, and from that point on it could be anyone within that pool of people.

    Hope this helps

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
  •