Webclat / Martech Practice
Webclat / Martech Practice  /  qa  /  matomo

Why does Matomo throw "_paq.push() was used but the tracker was not yet initialized"?

Answer in brief

This means a command reached the _paq array, or a tracker method was called directly, before the Matomo JS tracker file finished loading and processing the queue - usually because the snippet loaded asynchronously and something called a tracker method before that script executed, or because a duplicate _paq array shadowed the real queue.

Why this happens

Matomo's client-side tracker works like classic Google Analytics: _paq starts life as a plain JavaScript array that queues commands, and only becomes a "real" tracker once matomo.js loads and processes everything already sitting in the queue. If your page defines _paq in more than one place - a duplicate snippet, one copy from a tag manager and one hardcoded copy - or if code elsewhere calls tracker methods directly on Matomo.getTracker() before that call can succeed, you get this warning because the queue mechanism assumes only one array feeding one tracker instance.

Fix it

  1. Confirm the Matomo tracking snippet appears exactly once on the page - search your codebase and any tag manager container for duplicate insertions.
  2. Push all tracking calls through _paq.push([...]) syntax rather than calling Matomo.getTracker() synchronously elsewhere, unless you explicitly wait for the tracker to be ready.
  3. If you need the actual tracker instance, use the callback form: _paq.push([function() { var tracker = this; }]) - it runs only once the tracker is truly ready, avoiding the race entirely.
  4. In single-page apps, route route-change tracking through _paq.push() as well, not a direct method call that assumes the tracker object already exists.
  5. Check script load order if you self-host matomo.js behind a CDN or reverse proxy - a slow or blocked load of that one file is the most common actual root cause behind the warning appearing intermittently.

How to verify it worked

Open the console and run typeof _paq !== "undefined" && _paq.length - after the tracker has loaded, previously queued commands should have drained (length near 0). In Matomo's admin, use the Real-Time Visitors widget to confirm a manual page visit registers within seconds.

Still Seeing This After Trying the Fix?

Send us what you are seeing - the console error, the Network tab, the Live View output. We trace tracking implementations for a living and can usually tell you what is actually happening in one look.

Ask An Engineer