Kodunuzu setTimeout içine alarak çalışmasını erteleyebilirsiniz(event loop'un sonuna atar).

Örneğin:

Kod:
function hello(name) {
  console.log('hello ' + name);
}


hello('mars');

hello('world');
Çıktı:
"hello mars"
"hello world"
Kod:
function hello(name) {
  console.log('hello ' + name);
}

setTimeout(() => {
  hello('mars');
});

hello('world');
Çıktı:
"hello world"
"hello mars"
Bunu yaparak kendi kodunuzun Google Analytics kodundan(senkron olan kodundan) sonra çalışmasını sağlayabilirsiniz.