Skip to content
Snippets Groups Projects
Commit 3286d81c authored by khawkins98's avatar khawkins98
Browse files

catch when ga is undefined

mitigates https://github.com/ebiwd/EBI-Framework/pull/96
parent 6eed831a
No related branches found
Tags v1.2-alpha.1
No related merge requests found
......@@ -15,10 +15,12 @@ var numberOfEbiGaChecks = 0;
var numberOfEbiGaChecksLimit = 2;
var lastGaEventTime = Date.now(); // track the last time an event was send (don't double send)
function ebiGaCheck() {
if (ga && ga.loaded) {
jQuery('body').addClass('google-analytics-loaded'); // Confirm GA is loaded, add a class if found
ebiGaInit();
} else {
try {
if (ga && ga.loaded) {
jQuery('body').addClass('google-analytics-loaded'); // Confirm GA is loaded, add a class if found
ebiGaInit();
}
} catch (err) {
if (numberOfEbiGaChecks < numberOfEbiGaChecksLimit) {
numberOfEbiGaChecks++;
setTimeout(ebiGaCheck, 900); // give a second check if GA was slow to load
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment