Restore “ga” tracker variable name after Yoast Google Analytics “__gaTracker” transition

You may have noticed, guys at Yoast recently changed their base tracker variable name to __gaTracker for whatever reason.

Yes, this alternative name is given in the official Google Analytics documentation with the headline Renaming the Global Object in case “ga” is already used on the page. I have seen no insights from Yoast’s issue tracker to why they felt it was needed to change this variable and it broke people’s sites when their “ga()” calls were suddenly erroring.

Paste the following snippet into the “Advanced” tab -> “Custom Code” box of Yoast’s analytics plugin:

__gaTracker( function() {
  window.ga = __gaTracker;
} );

This fires the variable assignment once the tracker is loaded link. That happens whenever in the case of asynchronous loading (= everybody these days).

This snippet should keep your “ga”-based integrations alive and well, for example Wistia video tracking.

About Leho

Comments