Skip to content

Commit

Permalink
fix metrika-yandex-tag
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Nov 9, 2022
1 parent f55b7ad commit 90a0f04
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/redirects/metrika-yandex-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export function metrikaYandexTag(source) {
function ym(id, funcName, ...args) {
return api[funcName] && api[funcName](id, ...args);
}
ym.a = [];

function init(id) {
// yaCounter object should provide api
Expand All @@ -114,12 +113,13 @@ export function metrikaYandexTag(source) {

if (typeof window.ym === 'undefined') {
window.ym = ym;
ym.a = [];
} else if (window.ym && window.ym.a) {
// Get id for yaCounter object
const counters = window.ym.a;

// Keep initial counters array intact
ym.a = window.ym.a;
window.ym = ym;
counters.forEach((params) => {

window.ym.a.forEach((params) => {
const id = params[0];
init(id);
});
Expand Down

0 comments on commit 90a0f04

Please sign in to comment.