Google Analytics by Yoast is a must have plugin for all WordPress installs. It makes adding GA trackers a breeze and it can also ping certain events to Google Analytics. The only unexplained bit of code is the issue. At some point, the ‘ga’ variable changed to ‘__gaTracker’. This raised some concerns among the techy folk.
The change affects anyone adding custom bits of Google Analytics code such as event tracking. Mostly, people would probably notice their Contact Form 7 event tracking stop working. There is a solution to this by changing all your custom trackers from ‘ga’ to ‘_gaTracker’.
The other safer way would be to remap ‘_gaTracker’ to ‘ga’ and that will allow both trackers to work. To do this, open up your Yoast Google Analytics > Settings > Advanced tab and navigate to the “Custom code:” field. Enter the following:
[js]
__gaTracker( function() {
window.ga = __gaTracker;
});
[/js]
This simply waits for ‘_gaTracker’ to be set and then assigns ‘_gaTracker’ to ‘ga’. Now, both ‘ga’ and ‘_gaTracker’ will work fine.