Last active
July 10, 2018 14:24
-
-
Save Rhincodon/d8558580460c66dc95bd47df12a0c860 to your computer and use it in GitHub Desktop.
P20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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