Last active
December 8, 2017 21:36
-
-
Save doublejosh/a7481f547feb1be797db557f6e52e1b3 to your computer and use it in GitHub Desktop.
Eloqua tracking script - slightly better namespacing
This file contains 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
/** | |
* @file Eloqua visitor tracking. | |
*/ | |
var Eloqua = Eloqua || {}; | |
(function(Eloqua, window, _elqQ) { | |
Eloqua.timerId = null; | |
Eloqua.timeout = 5; | |
/** | |
* Retrieve Eloqua GUID and set form field value. | |
* | |
* Copied from Eloqua docs (and namespaced)... | |
* https://docs.oracle.com/cloud/latest/marketingcs_gs/OMCAA/#Help/EloquaAsynchronousTrackingScripts/Tasks/RepostingExternalForms.htm | |
* | |
* @todo Create promise function to retrieve GUID vs this nonsense. | |
*/ | |
Eloqua.waitForEloquaGUID = function () { | |
if (!!(Eloqua.timerId)) { | |
if (Eloqua.timeout == 0) { | |
return; | |
} | |
if (typeof window.GetElqCustomerGUID === 'function') { | |
document.getElementById('signup-form').elements.elqCustomerGUID.value = GetElqCustomerGUID(); | |
return; | |
} | |
Eloqua.timeout -= 1; | |
} | |
Eloqua.timerId = setTimeout(Eloqua.waitForEloquaGUID, 500); | |
return; | |
}; | |
// Fire on window load. | |
window.onload = Eloqua.waitForEloquaGUID; | |
// Issue request for ID from Eloqua server. | |
_elqQ.push(['elqGetCustomerGUID']); | |
}(Eloqua, window, _elqQ)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment