SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist tangledman's Avatar
    Join Date
    Sep 2005
    Location
    Puerto de Mazarron, Murcia, Spain
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirect problem.

    Hello from I have a bunch of adverts on my website, http://www.spanishpropertymagazine.com/. In order to count the number of click throughs I use the following code.

    It works, but I don't think google analytics picks up the traffic because of the redirect.

    How can I get google analytics to pick up the redirect?

    PHP Code:
    <?


    $query
    "SELECT advert_id, advert_image, advert_shown FROM advert WHERE advert_live = 'yes' $advert_type $advert_order $advert_limit";
    //echo "$query<br>";
    $result mysql_query($query);
    while (
    $array mysql_fetch_assoc($result)) {

        
    $advert_id $array['advert_id'];
        
    $advert_image $array['advert_image'];
        
    $advert_shown $array['advert_shown']+1;

        echo 
    "<a href=\"http://www.spanishpropertymagazine.com/advert_redirect.php?advert_id=$advert_id\" target=\"_blank\">
        <img src=\"http://www.spanishpropertymagazine.com/images/adverts/
    $advert_image\">
        </a>"
    ;


        
    $update_query="UPDATE advert SET advert_shown = '$advert_shown' WHERE advert_id ='$advert_id'"
        
    mysql_query($update_query);
    }


    ?>
    The user is sent to a redirect script.

    PHP Code:
    <?

    include "connect.inc.php";

    $advert_id $_GET['advert_id'];

    $query "SELECT advert_link, advert_click_count FROM advert WHERE advert_id = '$advert_id'";
    $result mysql_query($query);

    while (
    $array mysql_fetch_assoc($result)) {

    $advert_link $array['advert_link'];
    $advert_click_count $array['advert_click_count'] + 1;
    mysql_query("UPDATE advert SET advert_click_count = '$advert_click_count' WHERE advert_id = '$advert_id'");

    }

    $redirect "Location $advert_link";

    //echo "$redirect";
    header("Location: $advert_link");
    ?>
    Last edited by ScallioXTX; Jun 4, 2010 at 11:11.

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can I get google analytics to pick up the redirect?
    AFAIK, to be tracked by google analytics you need to put some codes (javascript script/code) in the redirect page and you have to have a script that waits at least for a few seconds to stay the page for a while.

    But I think this is really related to something Search Engine Optimization related question so better would be better if some moderators move this to corresponding forum. But what I think is '
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


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
  •