Skip to content

Instantly share code, notes, and snippets.

@lennardtastic
Last active August 13, 2018 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lennardtastic/9ce12b33aed9e28f4c72c603fae8b086 to your computer and use it in GitHub Desktop.
Save lennardtastic/9ce12b33aed9e28f4c72c603fae8b086 to your computer and use it in GitHub Desktop.
/**
* Sending custom variables as one object.
* This by default will allow you to add any additional values if you resend the customObj.
*/
// Define an object to hold the custom variables
var customObj = {};
// Define and set variables
var usernameU = "McAwesome";
var sessionU = "12afe34df";
var referrerU = "" + document.referrer;
// Fill the customObj with the earlier created custom variables
customObj.Username = usernameU;
customObj.SessionID = sessionU;
customObj.DocumentReferrer = referrerU;
//Send custom variables by assigning the customObj to the 'custom' object in Usabilla
window.usabilla_live('data', {
'custom': customObj
});
/** Updating/appending custom variables using one object
* If you want update or append value to the Custom Variables you can simply use the customObj.
* Update or append any value that you have and update them in the customObj and resend it again using the customObj
*/
// Update the variables and value
usernameU = "McAwesomeNew";
//Update or append them to the customObj
customObj.Username = usernameU;
//Resend if you changed/added values in the customObj
window.usabilla_live('data', {
'custom': customObj
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment