diff --git a/src/web_accessible_resources/google-analytics_analytics.js b/src/web_accessible_resources/google-analytics_analytics.js index 7ae84ff0f..aa4668bf0 100644 --- a/src/web_accessible_resources/google-analytics_analytics.js +++ b/src/web_accessible_resources/google-analytics_analytics.js @@ -79,11 +79,17 @@ dl.hide.end(); } if ( typeof dl.push === 'function' ) { - dl.push = function(o) { - if ( o instanceof Object && typeof o.eventCallback === 'function' ) { - setTimeout(o.eventCallback, 1); - } + const doCallback = function(item) { + if ( item instanceof Object === false ) { return; } + if ( typeof item.eventCallback !== 'function' ) { return; } + setTimeout(item.eventCallback, 1); }; + if ( Array.isArray(dl) ) { + for ( const item of dl ) { + doCallback(item); + } + } + dl.push = item => doCallback(item); } } // empty ga queue