1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Adwords php script

Discussion in 'PHP & Perl' started by sn1337, Aug 6, 2012.

  1. sn1337

    sn1337 Newbie

    Joined:
    Aug 6, 2012
    Messages:
    7
    Likes Received:
    0
    Hello all, my first post here, exciting :)

    I have a question regarding a php script which guides visitors to the correct page based on their search term, let me explain:

    I run a coupon website and used to bid on the merchant name plus the term coupon or coupons as an exact term, for an example (Sears coupon) but I started to get emails from the different affiliate networks saying that I was breaking their policy as I was bidding for brand names.

    After doing some research I noticed that some other coupon sites still showed up for several merchant related terms and after contacting my affiliate manager he told me that they bid on the broad term coupon and then use a php server script to guide visitors to the correct pages.

    So someone who searches for Sears coupon will be directed to the Sears page And someone looking for Dell coupon will be directed to the Dell page.

    Anyone knows which script this is and where I can get it?

    Many thanks
     
  2. loki_

    loki_ Registered Member

    Joined:
    May 20, 2012
    Messages:
    63
    Likes Received:
    8
    Location:
    #!/bin/bash/
    idk if something like that has been posted publicly but making shouldn't be much of an issue. you only need two things to get this going:
    $_SERVER['HTTP_REFERER'] and reading the google uri. All you need is in there.
     
  3. sn1337

    sn1337 Newbie

    Joined:
    Aug 6, 2012
    Messages:
    7
    Likes Received:
    0
    Thanks for this, did a search on google but couldn't find any extra information about it.

    Would you be able to provide me with a bit more information?

    Thank you
     
  4. loki_

    loki_ Registered Member

    Joined:
    May 20, 2012
    Messages:
    63
    Likes Received:
    8
    Location:
    #!/bin/bash/
    as i said-those are the kind of things you won't find on google. And most people on here wouldn't tell you either even if they know. However I have a slightly different approach-knowledge is freedom. So let's take a look at the following situation:
    I go on google and look for let's say "CentOS VPS".
    this will take me here:
    Code:
    http://www.google.com/#hl=en&output=search&sclient=psy-ab&q=CentOS+VPS&oq=CentOS+VPS&gs_l=hp.3..0l4.91.91.0.418.1.1.0.0.0.0.207.207.2-1.1.0...0.0...1c.TYavGYb2sVw&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&fp=873c21b8ed1f1648&biw=1600&bih=812

    And when I click any of the links the browser will pass on to the server where I've come from. PHP has access to that information via $_SERVER['HTTP_REFERER']. In some cases google will redirect you through a second url and you will see something else but that's to my experience about 10% of the searches. Take a look in their documentation if you want, those cases are probably explained somewhere. In all other cases you will see
    Code:
    http://www.google.com/#hl=en&output=search&sclient=psy-ab&q=CentOS+VPS&oq=CentOS+VPS&gs_l=hp.3..0l4.91.91.0.418.1.1.0.0.0.0.207.207.2-1.1.0...0.0...1c.TYavGYb2sVw&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&fp=873c21b8ed1f1648&biw=1600&bih=812

    So all you have to do is extract the keywords. And as you can see-it is right there. so you just have to play a bit. Jut to give you a headstart:


    Code:
    $r=$_SERVER['HTTP_REFERER'];
    $keywords=explode('&', $r);
    foreach ($keywords as $k){
        $lookup=explode('=', $k);
        if($lookup[0]=='q'){
            $google_keywords=explode('+', $lookup[1]);
        }
    }
    

    The above code should(I haven't tested it) give you an array with the exact google query the user gave.
    Array
    (
    [0] => centos
    [1] => vps
    )


    So your job will be to redirect your visitor to the right place using that information based on some logic that you will have to implement.
     
    Last edited: Aug 8, 2012
  5. sn1337

    sn1337 Newbie

    Joined:
    Aug 6, 2012
    Messages:
    7
    Likes Received:
    0
    Cool, thank you very much!

    Will have a go at it and let you know how I get on.
     
  6. loki_

    loki_ Registered Member

    Joined:
    May 20, 2012
    Messages:
    63
    Likes Received:
    8
    Location:
    #!/bin/bash/
    Just noticed I had missed a "+" in the code. You will need to add that.