- Home
- JavaScript
- How To Tell If Google Analytics Is Loaded with Javascript
How To Tell If Google Analytics Is Loaded with Javascript
The Problem:
Sometimes if we copied a site or if we’re writing a third party library, we may not know whether Google analytics has been loaded.
The Trick
Google analytics using a function it defines in the global context called “ga”.
How It Works:
Simply open your console and run the following (or build into your JavaScript code):
typeof ga === 'function'
If this returns true, Google analytics has been loaded, if false, then Google analytics has not been loaded or is currently loading.
Screenshot of Console Solutions to Check if Google Analytics is Loaded JavaScript: