Skip to content

Instantly share code, notes, and snippets.

@doublejosh
Last active December 8, 2017 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doublejosh/a7481f547feb1be797db557f6e52e1b3 to your computer and use it in GitHub Desktop.
Save doublejosh/a7481f547feb1be797db557f6e52e1b3 to your computer and use it in GitHub Desktop.
Eloqua tracking script - slightly better namespacing
/**
* @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