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

Track keyword from google -> landingpage -> affiliate

Discussion in 'HTML & JavaScript' started by snaps, Jul 9, 2010.

  1. snaps

    snaps Newbie

    Joined:
    Nov 30, 2008
    Messages:
    29
    Likes Received:
    2
    Hi..

    Im a little confused.

    Im using an affliate where i can add {keyword} to the affiliate link, to track which keywords convert. But im not using direct traffic, instead i have a landingpage. How can i cache the {keyword} from google to my landingpage, so it gets inserted in my affiliate links?

    Thanks.. Hope ive wrote this to confusing :)
     
  2. hi.imandrew

    hi.imandrew Junior Member

    Joined:
    Nov 22, 2009
    Messages:
    159
    Likes Received:
    42
    Location:
    Arkansas, USA
    Well, and I may not be the best to ask, and maybe someone else can verify.
    But what I would try doing is getting the referrer of the user. I would think if they clicked on it from google it would have the keyword in it.
    If you're using PHP, $referer = $_SERVER['HTTP_REFERER'];
     
    • Thanks Thanks x 1
  3. zestoi

    zestoi Newbie

    Joined:
    Mar 9, 2010
    Messages:
    41
    Likes Received:
    3
    yep - exactly that. that's also how you'd syntax hilite the page etc as some sites do.

    you'd need different regexes for each search engine - but this will work for google:

    PHP:
    if (preg_match('!google\..*q=(?P<kw>\S+?)&!'$_SERVER['HTTP_REFERER'], $cap))
    {
        
    $keywords $cap['kw']; // if u urldecode() remember to urlencode() too
        
    $track "google-hit:$keywords";
    }

    $afflink "http://blah.com?affiliate=me&track=$track";
     
    • Thanks Thanks x 1
  4. snaps

    snaps Newbie

    Joined:
    Nov 30, 2008
    Messages:
    29
    Likes Received:
    2
    Wow..
    Thanks guys.

    Perfect, testing it now.
     
  5. undelia

    undelia Newbie

    Joined:
    May 2, 2010
    Messages:
    40
    Likes Received:
    3
    I'm trying to get a hang of this as well. With landing pages, I normally use Statcounter or Google Analytics to track my keywords.