Record clicks on absolute url?

Discussion in 'PHP' started by ads2help, Feb 8, 2009.

  1. #1
    I need to record clicks when someone clicked on a absolute url.

    If the link is record.php?id=x then its easy to do that. However, I need the absolute url to be indexed by search engine so I cant do that ( am I right actually? )

    What I think of now is record the clicks using javascript.

    <a href="" onclick="ajax_function()"></a>
    Code (markup):
    Is there any other way?

    Thank you.
     
    ads2help, Feb 8, 2009 IP
  2. darrenbeige

    darrenbeige Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'd stick with the PHP route, making sure the PHP code 301's to the 'normal' URL. There will still be a sacrifice though, but thats the price you pay for recording stats.

    I don't see why you just plug Google Analytics in (JS code) meaning YOU don't have to do anything...
     
    darrenbeige, Feb 8, 2009 IP
  3. SedNaX

    SedNaX Active Member

    Messages:
    1,326
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    90
    #3
    You have to do it with javascript. It won't work easily on PHP.

    Link directory scripts (like phpld) also do it with javascript
     
    SedNaX, Feb 9, 2009 IP
  4. darrenbeige

    darrenbeige Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Its not hard; see sample psuedocode

    
    <?
    $url = $_GET['id'];
    // connect to mysql
    
    //select row $url and increment by 1
    
    //end mysql
    
    header(Location: $url);
    
    ?>
    
    Thats some example code. Its certainly not convoluted.
    Code (markup):
     
    darrenbeige, Feb 9, 2009 IP
  5. SedNaX

    SedNaX Active Member

    Messages:
    1,326
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    90
    #5
    He wants to do it without a ?id=...

    Instead of going first to mydomain.com?id=x, increment by 1 and go to otherdomain.com the OP wants to increment by 1 and go to otherdomain.com without going to mydomain.com?id=x first, so the search engines will index otherdomain.com, not mydomain.com?id=x. At least that's how I understand it...
     
    SedNaX, Feb 9, 2009 IP
  6. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #6
    Yes, That's what I mean.

    Hmm..I think I will go for ajax/javascript then.
     
    ads2help, Feb 15, 2009 IP