PHP, add Google Analytcs

Discussion in 'PHP' started by continuative, Dec 11, 2008.

  1. #1
    The page script below is the one I believe the code needs to go into, can someone assist please.

    Begin PHP code -------------------->

    <?php


    require("functions.php");
    require("configuration.php");

    connect();

    // Fetch Keys
    $keys = explode("/", $_SERVER['REQUEST_URI']);

    // Fetch URL
    $query = "SELECT * FROM `".$main_table."` WHERE `key1`='".$keys['2']."' AND `key2`='".$keys['3']."' AND `key3`='".$keys['4']."' AND `key4`='".$keys['5']."' AND `key5`='".$keys['6']."'";
    $result = mysql_query($query);
    $array = mysql_fetch_array($result);


    // Update click-throughs
    $array['clicks-aug'] = $array['clicks']+1;
    $query_update_clicks = "UPDATE `".$main_table."` SET `clicks`='".$array['clicks-aug']."' WHERE `id`='".$array['id']."'";
    mysql_query($query_update_clicks);


    // Forward
    header("Location:".$array['target']);


    ?>

    <------------ End PHP code
     
    continuative, Dec 11, 2008 IP
  2. Shoro

    Shoro Peon

    Messages:
    143
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can't put google analytics code on a page that forwards by sending a header.
     
    Shoro, Dec 11, 2008 IP
  3. continuative

    continuative Peon

    Messages:
    42
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you for your reply.

    What can be done to create a way to track the hit, either an additional page or process, any ideas would be appreciated.
     
    continuative, Dec 11, 2008 IP