How to track redirects?

Discussion in 'PHP' started by lopes, Nov 25, 2009.

  1. #1
    I have a file called redir.php that has something like this:

    <?php
          switch ($_GET['url']) 
          {
          case "666":
            header("Location: http://www.google.com");          
            break;
          case "100":
            header("Location: http://www.yahoo.com");          
            break;
        }       
    
    PHP:
    How do I implement analytics tracking in it?
    Ps: I can use any software except Google Analytics to do it.
     
    lopes, Nov 25, 2009 IP
  2. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #2
    do a table called redirs with id and location, counter fields or id and case,counter fields
    then into each case just drop a query with incrementing counter=counter+1
     
    crivion, Nov 25, 2009 IP
  3. LittleJonSupportSite

    LittleJonSupportSite Peon

    Messages:
    386
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I would create a small script that inserts the ref into a table with that session ID and URL it came form and was redirected to.

    Then redirect them.

    Now on other pages have a check_session(); function that will read over the table for a matching session and you can get really crafty with what to display because you know where they came from and where they are.

    At the end of the destroyed session just archive the data.
     
    LittleJonSupportSite, Nov 26, 2009 IP