We help IT Professionals succeed at work.
Get Started

How to get the parameters I need into the URL

442 Views
Last Modified: 2015-03-21
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?
Comment
Watch Question
Marketing Technologist
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 3 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE