Results 1 to 2 of 2

Thread: Referrer Tracking

  1. #1
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Referrer Tracking

    Hey Guys,

    I'm looking for a php script that will show the website and keyword used (if from a search engine) to find my site...


    For example:

    http://www.google.co.uk/search?hl=en&q=mysite&meta=

    $site = google
    $keyword = mysite

    I would like this to work for:
    MSN
    Google
    Yahoo
    and Ask Jeeves..

    If the referer is not a search engine:

    www.examplereferrersite.com/bla-bla-bla.html

    $site = examplereferrersite.com
    $keyword = (blank)

    Does anyone know how to do this??

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ooh, yes. Well, I can do google, anyway. You should be able to figure out the rest.
    PHP Code:
    $st $_SERVER['HTTP_REFERER'];
    $host;
    $keywords;
    if(
    strpos($st"google")) {
      
    $host "google";
      
    $st substr(strpos($st"q="));
      
    $st substr(0strpos($st"&")) > strpos($st"&") : strlen($st);
      
    $st substr(0substr($st"&") > strpos($st"&") : strlen($st);
      
    $st preg_replace('/\+/g'" "urldecode($substr));
      
    $keywords $st;

    Making it work with other search engines is a simple matter of working out what their GET variables are called, and so on and so forth.
    Note: this is a more-or-less direct port of the Javascript script I wrote in this thread.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •