Skip to content

Instantly share code, notes, and snippets.

@lennardtastic
Created January 26, 2018 16:24
Show Gist options
  • Save lennardtastic/b0beb0db58940cd9c427fbbf959a50fe to your computer and use it in GitHub Desktop.
Save lennardtastic/b0beb0db58940cd9c427fbbf959a50fe to your computer and use it in GitHub Desktop.
// Define or retrieve an object to hold the custom variables
var usblCustom = window.usblCustom || {};
// Loop through the Monetate Campaigns and add values to usblCustom Object.
// Please note, that the Monetate campaign object is only available within the Monetate "Custom Report" JavaScript console.
for (var i = 0; i < campaigns.length; i++) {
var monetateCounter = i.toString;
usblCustom["MonetateId-" + monetateCounter] = campaigns[i].id;
usblCustom["MonetateKey-" + monetateCounter] = campaigns[i].key;
usblCustom["MonetateSplit-" + monetateCounter] = campaigns[i].split;
//Send custom variables by assigning the customObj to the 'custom' object in Usabilla
window.usabilla_live("data", {
"custom": usblCustom
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment