Last active
December 10, 2019 16:58
-
-
Save JoeDoyle23/19b9d7ebd6f59ae70b8dcdb8ab3d1b34 to your computer and use it in GitHub Desktop.
dynamic shim load with callback
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
function loadUserLeapAndRun(callback) { | |
if (!window.UserLeap) { | |
window.UserLeap = function(){U._queue.push(arguments)} | |
let U = window.UserLeap;U.appId = 'xxxxxxxxx';U._queue = []; | |
let a=document.createElement('script'); | |
a.async=1;a.src='https://cdn.userleap.com/shim.js?id='+U.appId; | |
p=document.getElementsByTagName('script')[0]; | |
p.parentNode.insertBefore(a, p); | |
} | |
} | |
if (some_app_state) { | |
// loads the shim.js if not already loaded and executes the setUserId operation | |
loadUserLeapAndRun(); | |
UserLeap('setUserId', '[INSERT (ANONYMIZED) USER ID]'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment