Displaying search string in URL on web page?

Discussion in 'PHP' started by NAZAM.COM, May 1, 2007.

  1. #1
    I have been unable to find a script which would show a search string in the URL on my landing page.

    I am intending to use it to take the search made by a user in Google and then pull the search term from the URL and display it prominently on the landing page (to increase conversion rates).

    (Any affiliates attest to whether this can be effective with PPCing?)

    I would be using Google's {KeyWord} to show the search string after the URL.

    My friend told me it is a two line script, but it is beyond my programming knowledge. Any geniuses out there?

    Many thanks.
     
    NAZAM.COM, May 1, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    
    
    if (preg_match('/^http:\/\/(www\.)?google\.[a-z]{2,3}\/search\?.+q=([^&]+)/', $_SERVER['HTTP_REFERER'], $keywords))
    {
         // User comes from Google, and used these keywords:
         echo rawurldecode($keywords[2]);
    }
    
    ?>
    
    PHP:

    Not sure if I understood you right, but this should get the keywords the user used in his Google search.
     
    nico_swd, May 1, 2007 IP