D
D
DenimTornado2016-02-10 15:09:28
Google
DenimTornado, 2016-02-10 15:09:28

How does Google Analytics parse the request queue?

Hello!
Asynchronous Google Analytics works through a queue. Initially, an array is created, calls are added to it, and when either is loaded, the calls are executed. The question is how does this happen?
Let's assume that we have collected such an array:

var funcQuery = [
  ['firstFunc', 'UA-XXXXX-X'],
  ['secondFunc', '1'],
  ['thirdFunc', {"data":123}, 'bla bla'],
];

How then it is possible to make execute of functions from this array?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-02-10
@DenimTornado

window.firstFunc = function (p) {
  console.log('firstFunc', p);
}

window.secondFunc = function (p) {
  console.log('secondFunc', p);
}

window.thirdFunc = function (o, p) {
  console.log('thirdFunc', o, p);
}

var funcQuery = [
  ['firstFunc', 'UA-XXXXX-X'],
  ['secondFunc', '1'],
  ['thirdFunc', {"data":123}, 'bla bla'],
];

setTimeout(function () {
  for (var i = 0; i < funcQuery.length; i++) {
    window[funcQuery[i][0]].apply(null, funcQuery[i].slice(1));
  }
}, 2000);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question