Grabbing referring keyword and making it the sid?

Discussion in 'PHP' started by csutoras, Dec 15, 2006.

  1. #1
    I am sorry if this is already requested somewhere in the past. I looked through a few pages and saw nothing.

    I am trying to write some php to satisfy a need i have.

    I would like to make links on my page add an sid value based on the referring keyword used to get to the page.

    This is what i have gotten so far..

    <?php
    $ref=@$HTTP_REFERER; 
    if (strpos($ref,"google",0) )
    {
    $keyword = $_GET["q"];
    }
    
    elseif (strpos($ref,"yahoo",0) )
    {
    $keyword = $_GET["p"];
    }
    
    elseif (strpos($ref,"msn",0) )
    {
    $keyword = $_GET["q"];
    }
    
    else
    {
    $keyword = "none";
    }
    
    ?>
    Code (markup):
    <a href="http:mydomain.com?sub=rock+<?php echo $keyword; ?>">
    Code (markup):
    My goal is that the link on the page would add the referring keyword after rock+ and allow me to track the way i want to.

    When i put this code on the site and run it i get nothing after the + sign when coming from PPC links and +none when coming from an actual web site i set up a link on to test.

    Any help would be greatly appreciated. I have scoured the web and tried alot of examples but nothing seems to be working for me.
     
    csutoras, Dec 15, 2006 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    nico_swd, Dec 16, 2006 IP