Is it possible to do this kind of redirect using PHP?

Discussion in 'PHP' started by mzakih, Jan 12, 2007.

  1. #1
    Hi guys,

    I want to track non-Adwords traffic to my CB affiliate links using Google multi-channel conversion tracking and Google requires us to use a javascript code plus a given tracking link.

    Since I can't put Google's javascript code in the merchant's page, the way I do this is by using a delayed redirect page, where I put the javascript code. So when the visitors arrive using the tracking link, he/she will arrive in the redirect page to interact with the javascript code, then after that, he/she will get redirected to the merchant's page.

    I have tried using a javascript delayed redirect and it works, but I want to know if it's possible to do this using php? It seems that the most popular redirect code in php is the header("location"), but the problem is that it must run before any output being sent to the browser.

    So, how to do the above with php? Is it possible?

    Thanks,
    Zaki
     
    mzakih, Jan 12, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    
    header('Refresh: 2; URL="http://your-page.com"'); 
    
    PHP:
     
    nico_swd, Jan 12, 2007 IP
  3. Edynas

    Edynas Peon

    Messages:
    796
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    But dont you have only the clicks thru now and not the sales?
     
    Edynas, Jan 12, 2007 IP
  4. mzakih

    mzakih Active Member

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    96
    #4
    Hi nico_swd,

    Thanks for the code. I've tried it and it works.

    Btw, I heard that "refresh" is not in the official http specifications, so it may have problems with some browsers. For example, I heard that it has problem with Safari, because it adds an extra space in the url.

    So I wonder which one is better to use, the javascript redirect that may not work in browsers that turn javascript off or the header('refresh') that may have problems with some browsers?

    For Edynas:

    If I'm not mistaken, Adwords multi-channel conversion tracking has two javascript codes, one is for tracking the clicks (for landing page, etc.) and another is for tracking the sales (for product download page, etc.). I was asking about the javascript code that track the clicks.

    As for tracking affiliate sales, it may be good if we can ask the merchant to put the other javascript code in the product download page or any "after sales" page. But even if we can't, CB still gives us option to track sales using the ?tid= in the url.

    Regards,
    Zaki
     
    mzakih, Jan 13, 2007 IP
  5. mzakih

    mzakih Active Member

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    96
    #5
    Sorry for bringing this issue again, but found out that it seems in IE, the usage of the header('refresh') makes the visitors come back to the redirect page again (and not to the page before the redirect page) when they click the back button. This may inflate the conversion stats and annoy the visitors.

    Is there a way to make them return to the page before the redirect page, like what the location.replace do in javascript?

    Thanks,
    Zaki
     
    mzakih, Jan 15, 2007 IP