0

Check to see if segment is blocked

So I'm wondering if there is a way to check to see if browser is blocking Segment via an adblocker like Ghostery.

An Example to check to see if GA is loaded:

window.addEventListener('load', function () {
if (window.ga && ga.create) {
console.log('Google Analytics is loaded');
} else {
console.log('Google Analytics is not loaded');
}

//THIS DOES NOT WORK
if (window.analytics && analytics.track) {
console.log('segement is loaded');
} else {
console.log('segment is not loaded');
}
}, false);

Can you guys provide a method in which I can throw an error if it is blocked. 

1reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  • Hi  Will ,

    Ghostery doesn't block analytics.js from loading on the page, but rather blocks it from full initializing. To check if has been blocked by Ghostery you can try checking if the window.analytics._readied property is undefined. This property will return true if analytics.js has been properly initialized on the page.

    Best,

    Xavier

    Reply Upvote