Link to home
Start Free TrialLog in
Avatar of smuralisankar
smuralisankar

asked on

How to get the parameters I need into the URL

This is the normal URL of the page:
http://freshservice.com/compare-it-service-desk

This is a landing page for a Google adwords campaign.

A developer was able to write a script that allowed the pulling of a keywords from Google adwords campaign and put it into the URL as query parameters.

He said that the original code does it using the Google API.

The script on this page pulls in the keyword that the user searched (Google adwords API) and populates it in the URL and then takes that KW and makes a change on the page.

For eg:

If someone searches for sysaid and sees/clicks on the ad and gets to the landing page, we see this:


This was the result:
http://freshservice.com/compare-it-service-desk?kw=sysaid

This is the code/script:

<script type="text/javascript">
function getParam ( sname )
{
  var params = location.search.substr(location.search.indexOf("?")+1);
  var sval = "";
  params = params.split("&");
    for (var i=0; i<params.length; i++)
       {
         temp = params[i].split("=");
         if ( [temp[0]] == sname ) { sval = temp[1]; }
       }
  return sval;
}



function process_keyword (sname)
{
  var apps = {};
  apps["servicenow"]="ServiceNow";
apps["service now"]="ServiceNow";
apps["cherwell"]="Cherwell";
apps["landesk"]="Landesk";
apps["connectwise"]="Connectwise";
apps["sysaid"]="Sysaid";
apps["track it"]="Track-It";
apps["ibm tivoli"]="IBM Tivoli";
apps["ca unicenter"]="CA Unicenter";
apps["frontrange heat"]="FrontRange Heat";
apps["frontrange"]="FrontRange";
apps["servicedesk plus"]="ServiceDesk Plus";
apps["autotask"]="Autotask";
apps["bmc remedy"]="BMC Remedy";
apps["bmc remedyforce"]="BMC RemedyForce";
apps["samanage"]="Samanage";
apps["hp service manager"]="HP Service Manager";
apps["topdesk"]="TopDesk";
apps["dell kace"]="Dell Kace";
apps["dellkace"]="DellKace";         
apps["manageengine"]="ManageEngine";
apps["citrix gotoassist"]="Citrix GoToAssist";
apps["jira service desk"]="JIRA Service Desk";
apps["numara footprints"]="Numara Footprints";
apps["zendesk for it"]="Zendesk for IT";
  keyword = unescape(getParam(sname));
  for (key in apps){
    if (keyword.toLowerCase().contains(key)){
      return apps[key];
    }
  }
  return "other Service Desks";
}

function set_data(sname){
  $('#replace_text').html("Why Freshservice is better than "+process_keyword(sname));
  var keyw = process_keyword(sname);
  if( keyw == "other Service Desks"){
  	$('#replace_text1').html("IT SERVICE DESK SOFTWARE");  
  }
  else{
    $('#replace_text1').html(process_keyword(sname).toUpperCase()+" Vs FRESHSERVICE");  
  }
  
}
</script>

Open in new window



This is the result that I am looking to achieve.
I would like to get the keyword, ad group name and campaign name into the URL.

This is the result I am looking for:

http://freshservice.com/compare-it-service-desk?otm_kw=sysaid&otm_adgroup=competition&otm_campaign=search_US


What is the code to get this done?
SOLUTION
Avatar of Lucas Bishop
Lucas Bishop
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of smuralisankar
smuralisankar

ASKER

What if I don't want the kw, adgroup or campaign name in the URL?

Everyone can see it then.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial