SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2001
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need Click Tracking Help

    I’m a php newbie, so bear with me. I use a php click tracking script that I downloaded from hotscripts. The script tracks the number of clicks for specified URLs. Like most of these scripts, to track the URL, you preface the link tag with the name of script that does the tracking (e.g., <A HREF=http://www.mysite.com/click.php?url=http://www.yahoo.com>Yahoo!</A>). When the link is clicked, click.php inserts the URL into a MySql table, as follows:

    $url = str_replace("http://", "", $url);
    $url = "http://$url";
    $getit = mysql_query("SELECT * FROM $dbtable WHERE url = '$url'") or die(mysql_error());
    if(mysql_num_rows($getit) <= 0){
    mysql_query("INSERT INTO $dbtable (url) VALUES ('$url')") or die(mysql_error());
    header ("Location: $url");
    }
    else{
    mysql_query("UPDATE $dbtable SET hits = hits + 1 WHERE url = '$url'") or die(mysql_error());
    header ("Location: $url");

    Here is my problem. I don’t want just the URL inserted into the database. I want both the URL and the name of the link (in the above example “Yahoo!”). Is there a way to do this? Would it help that all of the URLs have unique IDs that are stored in a separate MySql table that can be accessed?

    The bottom line is this…I want a page on my site that lists the links (by name) that are clicked on the most. Maybe there is another script out there that does this already?

    Thanks.

  2. #2
    epsilon transition cupid's Avatar
    Join Date
    Aug 2001
    Location
    Kent, Ohio
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure if getting the linked word is possible, but if you find a way to do it.. please let me know how. Thanks

  3. #3
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could alter the script so that you also have the name in the URL:

    http://www.mysite.com/click.php?url=...com&name=Yahoo

    Then when the URL is logged you could log the name

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2001
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    seanf

    I may be missing something, but if you add the "name" variable then you'll mess up the link, no? That is, the link wont work (i.e., <A HREF="...url=http://www.yahoo.com&name=Yahoo>Yahoo</A> wont take you to Yahoo's site).

  5. #5
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You will need to alter the script

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  6. #6
    SitePoint Zealot
    Join Date
    Mar 2001
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol...that's why I posted the question! I don't know how.

  7. #7
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make a jump script that will take an id or name.
    then, have the link something like www.yoursite.com/jump.php?id=32&name=Yahoo
    and in record 32 in your database have
    id | link_url | name

    the jump script would be something like this

    $link_id = $id;
    $link_name = $name; // do with this what you want.

    $sql = "SELECT * from links WHERE id = '$link_id'";
    $do_query = mysql_query($sql, $db_connect);
    $result = mysql_fetch_array($do_query);

    header("Location: $result[url]");
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


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
  •