Table of Contents

Google Analytics - Command Queue (q)

About

It's called the command queue because rather than executing the commands it receives immediately, it adds them to a queue that delays execution until the analytics.js library is fully loaded.

Management

See

The queue is the q array properties of the ga function.

console.log(ga.q);

Outputs the following:

[
   ['create', 'UA-XXXXX-Y', 'auto'],
   ['send', 'pageview']
]

where:

Execution

Once the analytics.js library is loaded, it inspects the contents of the ga.q array and executes each command in order. After that, the ga() function is redefined, so all subsequent calls execute immediately.

The command execute asynchonously and do not return a value.