1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

PHP code doesn't work, is it wrong? PHP Redirect code.

Discussion in 'Software Development' started by tnomal2008, May 31, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. tnomal2008

    tnomal2008 Thread Starter

    Joined:
    Aug 15, 2008
    Messages:
    5
    Can anyone assist? I'm not a programmer so please forgive me in advance.

    I’ve tested the code below but it’s not redirecting (no errors on the page) As an FYI, I tested only using two incoming links, I added the third elseif here for better clarification.

    ----------------------------------------------------------------------------------------------


    Problem:

    Need to capture campaign ID from print ads and/or direct links. An easy fix would be a tracking pixel on the page but our current analytics program does not provide it (can’t purchase another program, our company is too invested in the current).

    Goal:

    To just add another elseif expression for new print ads and/or redirects, i.e. until our analytics company develops a solution (simple as opposed to creating a sub domain w/ a redirect for each new incoming link)


    Important Notes:

    The code should be case sensitive because the incoming link may sometimes come from same domain but with a different campaign ID (see example below)

    I did manage to capture the campaign ID using to two domain autoforwards but that will only work for one incoming link.

    ----------------------------------------------------------------------------------------------

    EXAMPLE

    Print Ad URL #1 >>>domain autoforward>>> http://www.PurchasedDomain55.com/?utm_source=print&utm_campaign=PrintAD1 >>>php redirect>>> www.DestinationPage44.com/?utm_source=blog&utm_campaign= PrintAD1

    Print Ad URL #2 >>>domain autoforward>>> http://www.PurchasedDomain55.com/?utm_source=print&utm_campaign= PrintAD2 >>>php redirect>>> www. DestinationPage44.com/?utm_source=blog&utm_campaign= PrintAD2

    Print Ad URL #3 >>>domain autoforward>>> http://www.PurchasedDomain55.com/?utm_source=print&utm_campaign= PrintAD3 >>>php redirect>>> www. DestinationPage44.com/?utm_source=blog&utm_campaign= PrintAD3

    ----------------------------------------------------------------------------------------------
    CODE

    <?php $referrer = $_SERVER['HTTP_REFERER'];
    if (stripos($referrer, ' http://www.PurchasedDomain55.com/?utm_source=print&utm_campaign=PrintAD1 ') !== false)
    { header("location: www.DestinationPage44.com/?utm_source=blog&utm_campaign= PrintAD1"); }

    elseif (stripos($referrer, ' http://www.PurchasedDomain55.com/?utm_source=print&utm_campaign= PrintAD2 ') !== false)
    { header("location: www. DestinationPage44.com/?utm_source=blog&utm_campaign= PrintAD2"); }

    elseif (stripos($referrer, ' http://www.PurchasedDomain55.com/?utm_source=print&utm_campaign= PrintAD3 ') !== false)
    { header("location: www. DestinationPage44.com/?utm_source=blog&utm_campaign= PrintAD3"); }

    ?>
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1055271