I'm working on a project where the user would like to be able to add either "?2yr" or "?4yr" to the end of the URL, but when the user then clicks to another page pass that query along as well.
For example, http://example.com/index.html?2yr is the home page, but when you click say contact it would be http://example.com/powerful_predictors.html?2yr.
I've tried doing the following:
var _url = window.location;
if(window.location.href.indexOf("2yr") >- 1) {
console.log("your url contains the 2yr");
} else if(window.location.href.indexOf("4yr") >-1){
console.log("your url contains 4yr");
}
How might I add the "?2yr" or "?4yr" when the user clicks a URL to go to another page?