Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions js/foundationExtendEBI.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ var numberOfEbiGaChecks = 0;
var numberOfEbiGaChecksLimit = 2;
var lastGaEventTime = Date.now(); // track the last time an event was send (don't double send)
function ebiGaCheck() {
try {
if (ga && ga.loaded) {
jQuery('body').addClass('google-analytics-loaded'); // Confirm GA is loaded, add a class if found
ebiGaInit();
}
} catch (err) {
if (window.ga && window.ga.loaded) {
jQuery('body').addClass('google-analytics-loaded'); // Confirm GA is loaded, add a class if found
ebiGaInit();
} else {
if (numberOfEbiGaChecks < numberOfEbiGaChecksLimit) {
numberOfEbiGaChecks++;
setTimeout(ebiGaCheck, 900); // give a second check if GA was slow to load
Expand Down Expand Up @@ -57,7 +55,7 @@ function analyticsTrackInteraction(actedOnItem, parentContainer, customEventName
// Only if more than 100ms has past since last click.
// Due to our structure, we fire multiple events, so we only send to GA the most specific event resolution
if ((Date.now() - lastGaEventTime) > 150) {
ga && ga('send', 'event', 'UI', 'UI Element / ' + parentContainer, linkName);
window.ga && window.ga('send', 'event', 'UI', 'UI Element / ' + parentContainer, linkName);
lastGaEventTime = Date.now();

// conditional logging
Expand Down Expand Up @@ -151,7 +149,7 @@ function ebiGaInit() {
if ( keydown !== null ) {
var delta = new Date().getTime() - keydown;
if ( delta > 0 && delta < 1000 ) {
ga && ga('send', 'event', 'UI', 'UI Element / Keyboard', 'Browser in page search');
window.ga && window.ga('send', 'event', 'UI', 'UI Element / Keyboard', 'Browser in page search');
}
keydown = null;
}
Expand Down