Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save keshcreations/d2d8b1855a81d99905b1c164317f496e to your computer and use it in GitHub Desktop.
Save keshcreations/d2d8b1855a81d99905b1c164317f496e to your computer and use it in GitHub Desktop.
JavaScript for encoding URL with invalid characters
//setEventCallback That on campaign open or feedback open will retrieve the URL en encode it to make sure that non-encoded characters cause issues for using Usabilla.
window.usabilla_live("setEventCallback", function(category, action, label, value) {
var type = null;
var uri = "";
var res = "";
switch (action) {
case "Feedback:Open":
uri = window.location;
res = encodeURI(uri);
history.pushState('', document.title, res);
break;
case "Campaign:Open":
uri = window.location;
res = encodeURI(uri);
history.pushState('', document.title, res);
history.pushState('', document.title, res);
break;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment