Blogging tips

Tips how to create and maintain your blog


How to solve “Uncaught ReferenceError: ga is not defined” error

Uncaught ReferenceError: ga is not defined

Recently I updated Google Analytics by Yoast plugin on my WordPress site and all my custom Google Analytics events stopped working.

I was getting “Uncaught ReferenceError: ga is not defined” error.
It took awhile to figure out the problem, but fortunately it is easy to solve it.

The problem is Yoast without any explanation changed original Google Analytics javascript code and names function __gaTracker instead of original ga.

This is how looks Google Analytics Universal code:


And this is GA code after Yoast modification:


There are two ways to solve it.

The first way is to rename ga into __gaTracker in your source code. It is easy to do if you don’t use ga script heavily.

Second approach is useful if you have a lot of appearances of ga in your javascript code or you don’t have access to your source code.
In such case, you need go to Google Analytics by Yoast settings page in your website dashboard

Google Analytics Yoast settings: custom code

and add this custom code:

__gaTracker( function() { = __gaTracker;

Important: for testing of second solution you must log out from your website admin panel or test it in another browser. By default Google Analytics by Yoast doesn’t track logged user and this custom code won’t be executed.

This solution applies only to WordPress users who are using Goolge Analytics by Yoast plugin.


  1. It’s remarkable to pay a visit this website and reading the views of all colleagues concerning this article,
    while I am also keen of getting familiarity.

  2. But betting the virtual points may be a harmless activity as well.
    Don’t let your temper get the higher of you when you
    joker123 demo game poker or versus. Definitely a great place
    to start if you are beginner.

  3. I’ll immediately snatch your rss feed as I can’t
    to find your email subscription hyperlink or e-newsletter service.
    Do you have any? Please allow me know so that I may subscribe.
    Thanks. I simply couldn’t go away your web site prior to suggesting that I
    actually enjoyed the standard information a person provide in your guests?
    Is going to be back ceaselessly to check up on new posts Ahaa,
    its good conversation regarding this post at this place at
    this blog, I have read all that, so now me also commenting
    at this place.

Leave a Reply

Theme by Anders Norén