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

A script to pass Adwords Keyword through a mailform?

Discussion in 'General Scripting Chat' started by muchacho, Oct 6, 2009.

  1. muchacho

    muchacho Supreme Member

    Joined:
    May 14, 2009
    Messages:
    1,293
    Likes Received:
    187
    Location:
    Lancashire, England.
    1) Visitor Clicks Adwords Ad
    2) Lands on website and goes through to a fillout form
    3) Details are emailed to me and as well as it having the form fields such as name, address etc, it also includes the keyword that the person originally typed into Google to find my website.

    I'm sure it's possible but what's the most simple way of doing this?
     
  2. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    This code will show keyword typed in google:

    PHP:
    <?php

    $url
    =$HTTP_REFERER;

    $arr parse_url($url);
    $parameters $arr["query"];
    parse_str($parameters$data);
    $query=$data['q'];


    echo 
    $query;
    ?>
    use $query as a value of one of your form input.
    To make form use html but i think that you know already :D

    regards
    Cyklotrial
     
  3. muchacho

    muchacho Supreme Member

    Joined:
    May 14, 2009
    Messages:
    1,293
    Likes Received:
    187
    Location:
    Lancashire, England.
    Cyklotrial, thanks.

    A slight problem (well it might be a problem), is that the keyword only seems to be shown when the visitor lands on the landing page.

    Example:

    domain.com?kw={keyword}

    When they venture to the info pack page (where the form is), the ?kw={keyword} doesn't carry across as it's a normal hyperlink.

    So will the query need to be picked up and stored on the landing page (as a variable), before being called up again on the form page?
     
    Last edited: Oct 6, 2009
  4. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    save it in cookie :)
    and after user send form delete this cookie
     
  5. muchacho

    muchacho Supreme Member

    Joined:
    May 14, 2009
    Messages:
    1,293
    Likes Received:
    187
    Location:
    Lancashire, England.
    Sorry, but I have no idea how to do that, lol.

    Would it help if I PMd you the website in question?
     
  6. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    Main page:
    PHP:
    <?php
    $url
    =$HTTP_REFERER;

    $arr parse_url($url);
    $parameters $arr["query"];
    parse_str($parameters$data);
    $query $data['q'];

    setcookie("keywords"$query);
    ?>
    This code will save keyword in cookie

    Page with form:
    PHP:
    <?php
    $query 
    $_COOKIE["keywords"];
    ?>
    Now you can use $query to put keyword into your form

    Page where you are sending form:
    PHP:
    <?php
    setcookie 
    ("keywords"""time() - 3600);
    ?>
    This code will clear cookie and set expired date to an hour ago


    If you have any queston - shot me PM