Answered

How can I check if an adblocker has prevented the Messenger script from loading?

  • 9 September 2020
  • 1 reply
  • 315 views

Userlevel 2
Badge

Sometimes, adblockers mean that I don't always track every visitor or user on my site. How can I check if an adblocker has prevented the Messenger script from loading?

icon

Best answer by Eric Fitz 9 September 2020, 15:24

View original

1 reply

Userlevel 1

There is a way to know if Intercom Javascript has been blocked. You can use Intercom('onUnreadCountChange') as part of the JavaScript API.

 

It will trigger for pages that have Intercom loaded.

 

var intercomLoaded = false;

Intercom('onUnreadCountChange', function(unreadCount) {

  intercomLoaded = true;

});

 

Then the intercomLoaded variable could be used for any custom actions if needed.

 

This still won’t capture all instances of the Messenger being available (e.g. if Intercom is loaded but there is no initialisation or if there is an issue with the initialisation) but it is an alternative if needed.

Reply