Jump to content

Show Google Search Term That Brought Visitor to my Website?


cromagnon

Recommended Posts

Hi all

 

I like a script that can Show Google Search Term That Brought Visitor to my Website.

 

Example: People search for "flower baskets" and find my page in google result list. They pres the Google links and get to my page. Here they will read: "You find this page by seachring for "flower baskets".

 

I found this script, but it seems like its not working:

 

<?php   

$referer= $_SERVER['HTTP_REFERER'];

 

    //find the search query from google that brought them here

    $qref= strpos($referer,'google');

 

    if($qref!="){

    $qstart= strpos($referer,'q=');

    $qend= strpos($referer,'&',$qstart);

    $qtext= substr($referer,$qstart+2,$qend-$qstart-2);

    $qtext= str_replace('+',' ',$qtext);

    }

    echo $qtext

?>

 

Can anyone help me to fix the script or bring me a new script for this task?

 

Thanks in advance

 

Cromagnon

Link to comment
Share on other sites

Thanks. Very nice! It works.

 

But it prints danish letters a little strange.

 

Like: gucci bælter

 

It should be "gucci bælter".

 

How can I be sure that danish letters æ, ø, å will be written the correct way in the script?

 

Thanks!!!

Link to comment
Share on other sites

  • 4 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.