var refer = document.referrer; //gets the URL of the previous page (like a search engine)
 
    if( refer.match(/zuora.com/) || refer.length < 2 ) {  //only do this if its referer is not a zuora page or an empty refer
 
      //Do different things for different search engines
 
      if (refer.match(/yahoo.com/)) {
        searchEngine = "Yahoo";
        searchString = $(refer).getUrlParam("p");
      }
      else if (refer.match(/google.com/)) {
        searchEngine = "Google";
        searchString = $(refer).getUrlParam("q");
      }
      else if (refer.match(/live.com/)) {
        searchEngine = "Microsoft Live";
        searchString = $(refer).getUrlParam("q");
      }
      else if (refer.match(/search.msn.com/)) {
        searchEngine = "MSN Search";
        searchString = $(refer).getUrlParam("q");
      }
      else if (refer.match(/aol.com/)) {
        searchEngine = "AOL";
        searchString = $(refer).getUrlParam("query");
      }
	  else if (refer.match(/ask.com/)) {
        searchEngine = "ASK";
        searchString = $(refer).getUrlParam("q");
      }
	    else if (refer.match(/hotbot.com/)) {
        searchEngine = "HOTBOT";
        searchString = $(refer).getUrlParam("query");
      }
	  
      else {
        searchEngine = refer; //would be nice to do a regular expression and just get the domain
        searchString = "Unknown"; //we could also say "None"
      }
 
      payPerClickWord = $(document).getUrlParam("keyword");  //use some parameter in the ads to get the keyword.  If you use kw, change the value here.
 
      //put the answers into the cookies
      $.cookie('marketoPPCKeyword', payPerClickWord);
      $.cookie('marketoSearchEngine', searchEngine);
      $.cookie('marketoSearchString', searchString);
 
 
    }
 
    //Get the values from the cookies and put them into the hidden fields
    $("#Keyword_Phrase").attr("value",$.cookie('marketoSearchString'));
    $("#Search_Engine").attr("value",$.cookie('marketoSearchEngine'));
    $("#Ad_Group").attr("value",$.cookie('marketoPPCKeyword'));