Skip to content

Instantly share code, notes, and snippets.

@Rhincodon
Last active July 10, 2018 14:24
Show Gist options
  • Save Rhincodon/d8558580460c66dc95bd47df12a0c860 to your computer and use it in GitHub Desktop.
Save Rhincodon/d8558580460c66dc95bd47df12a0c860 to your computer and use it in GitHub Desktop.
P20
var eventsQueue = [];
var releaseQueue = function() {
if (!window.parentIFrame || eventsQueue.length <= 0) {
return;
}
eventsQueue = $.grep(eventsQueue, function(value) {
window.parentIFrame.sendMessage(value);
return false;
});
};
setInterval(releaseQueue, 500);
function reportStatus(action, outcome) {
// ... sending acitivity_id, screen, score (0-100)
eventsQueue.push({activity: activity_id, screen: screen, score: score});
}
// EVENT TRACKING
function reportEvent(eventName, data) {
eventsQueue.push({type: 'event', name: eventName, fields: data});
}
// EXAMPLE OF EVENT 1
$('img').on('click', function() {
reportEvent('Click on picture', {picture_url: $(this).attr('src')});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment