Skip to content

Commit

Permalink
catch when ga is undefined
Browse files Browse the repository at this point in the history
mitigates #96
  • Loading branch information
khawkins98 committed Jul 10, 2017
1 parent 6eed831 commit 3286d81
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions js/foundationExtendEBI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3286d81

Please sign in to comment.