S
S
Sergey Sokolov2017-03-15 12:37:03
JavaScript
Sergey Sokolov, 2017-03-15 12:37:03

How to provide banner cutters when working with Yandex.Metrica from a JS application?

There is a web application, a one-pager on Backbone, modules are loaded via RequireJS. Among other things, Yandex.Metrica and the VKontakte advertising network are loaded.
Many visitors have AdBlock or other extensions that block advertising and tracking scripts - Metrika (metrika / watch) and VK (vkpreroll, vkadman).
There are many places in the code where there are calls to the Metrica to collect statistics - event markings, for example App.Metrika.params({ auth_recheck: 1})
, in case the Metrica is not loaded, an alternative is written in the RequireJS config - a local stub module, an object with Metrica methods, only there are empty functions:

return {
  addFileExtension: function(){}
  , clickmap: function(){}
  // и т.д.

This crutch (?) has been working fine for several years, there are no problems with AdBlock Plus. But now I came across the fact that someone in Google Chrome has the Fair AdBlocker (by STANDS) extension blocking the stub too - an error occurs that the Metrika module is generally undefined .
What is the best way to ensure that scripts blocked by banner cutters do not cause errors for clients?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pushkarev, 2017-03-15
@AXP-dev

As a variant of exception?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question