Resolving the 'ga is not defined' JavaScript Conflict on Login Pages
Content
One of the most common and disruptive issues reported by users of the ExactMetrics plugin (formerly GADWP) is a JavaScript conflict that occurs on the WordPress login page. This problem often manifests as a "ga is not defined" error in the browser console and can prevent other critical functions, like two-factor authentication from Wordfence, from working correctly.
What Causes the "ga is not defined" Error?
The root cause is a setting within the ExactMetrics plugin. When the "Track form submit actions" option is enabled on the "Events Tracking" tab, the plugin injects a JavaScript click handler to track form submissions. This script runs on all pages, including wp-login.php.
The Google Analytics tracking code (analytics.js), which defines the ga() function, is intentionally not loaded on the login page for privacy and performance reasons. Therefore, when the plugin's event tracking script tries to call the non-existent ga() function, it throws a ReferenceError and halts the execution of any subsequent JavaScript on the page.
How to Identify the Problem
If you are experiencing login issues, especially with 2FA, follow these steps to confirm this is the cause:
- Open your browser's developer tools (F12).
- Navigate to the Console tab.
- Go to your WordPress login page.
- If you see an error like
Uncaught ReferenceError: ga is not defined, this guide applies to you.
How to Fix It
The most effective and immediate solution is to adjust the plugin's settings.
- Log into your WordPress admin dashboard.
- Navigate to ExactMetrics -> Settings.
- Click on the "Engagement" tab.
- Locate the "Events Tracking" section.
- Find the setting for "Track form submit actions" and disable it.
- Save your changes.
This prevents the plugin from attempting to track events on the login page, eliminating the JavaScript error and resolving the conflict with other scripts.
For Developers: A Code-Based Workaround
If you must keep form tracking enabled, a more technical solution involves adding a custom filter to your theme's functions.php file. This code will prevent the ExactMetrics events tracking script from loading on the login page entirely.
/**
* Dequeue ExactMetrics events tracking on the login page
*/
function my_dequeue_exactmetrics_login_script() {
if ( isset( $_SERVER['SCRIPT_NAME'] ) && strpos( $_SERVER['SCRIPT_NAME'], 'wp-login.php' ) !== false ) {
wp_dequeue_script( 'exactmetrics-frontend-script' ); // The script handle may vary.
}
}
add_action( 'wp_print_scripts', 'my_dequeue_exactmetrics_login_script' );
Note: Use this code with caution and always test on a staging site first. The exact script handle may change between plugin versions.
Conclusion
This conflict is a classic example of how a powerful feature in one plugin can inadvertently affect another. The ExactMetrics team has been made aware of this interaction in the past. For most users, simply disabling the "Track form submit actions" option provides a quick and complete resolution, allowing for a smooth login experience without sacrificing the core analytics functionality of the plugin.
Related Support Threads Support
-
The blue progress bar is loading slowly and no report/error is displayedhttps://wordpress.org/support/topic/the-blue-progress-bar-is-loading-slowly-and-no-report-error-is-displayed/
-
PHP Notice: wp_enqueue_script was called incorrectlyhttps://wordpress.org/support/topic/php-notice-wp_enqueue_script-was-called-incorrectly-4/
-
Conflicting with WP Masonry Layouthttps://wordpress.org/support/topic/conflicting-with-wp-masonry-layout/
-
Elementor Version 2.5.15https://wordpress.org/support/topic/elementor-version-2-5-15/
-
Small patch for gadwp_cache_ itemshttps://wordpress.org/support/topic/small-patch-for-gadwp_cache_-items/
-
Autoptimize Plugin & GADfWP not working togetherhttps://wordpress.org/support/topic/autoptimize-plugin-gadfwp-not-working-together/
-
Google Analytics Dashboard for WP (GADWP) and IE/Edgehttps://wordpress.org/support/topic/google-analytics-dashboard-for-wp-gadwp-and-ie-edge/
-
GADWP is breaking my XML sitemap & feed URLhttps://wordpress.org/support/topic/gadwp-is-breaking-my-xml-sitemap-feed-url/
-
Please check the DB requests and reduce themhttps://wordpress.org/support/topic/please-check-the-db-requests-and-reduce-them/
-
How to change color of front end widget?https://wordpress.org/support/topic/how-to-change-color-of-front-end-widget/
-
do your plugin spam on spacebarnot.work?https://wordpress.org/support/topic/do-your-plugin-spam-on-spacebarnotwork/
-
Frontend Widget Brokenhttps://wordpress.org/support/topic/frontend-widget-broken/
-
Plugin is stopping 2FA with Wordfence from workinghttps://wordpress.org/support/topic/plugin-is-stopping-2fa-with-wordfence-from-working/
-
Code is injected inline and is evaluatedhttps://wordpress.org/support/topic/code-is-injected-inline-and-is-evaluated/
-
Frontend widget doesn't workhttps://wordpress.org/support/topic/frontend-widget-doesnt-work/
-
GADWP Frontend Error (-32)https://wordpress.org/support/topic/gadwp-frontend-error-32/
-
Blank Screen on Saving Access Keyhttps://wordpress.org/support/topic/blank-screen-on-saving-access-key/
-
Javascript error on the login page causing a plugin conflicthttps://wordpress.org/support/topic/javascript-error-on-the-login-page-causing-a-plugin-conflict/
-
Conflict js with other pluginhttps://wordpress.org/support/topic/conflict-js-with-other-plugin/
-
Conflict with WP Performance Score Booster Settingshttps://wordpress.org/support/topic/conflict-with-wp-performance-score-booster-settings/
-
Stats not shown in Dashboardhttps://wordpress.org/support/topic/stats-not-shown-in-dashboard/
-
Page speed drops 15 points with plugin enabledhttps://wordpress.org/support/topic/page-speed-drops-20-points-with-plugin-enabled/
-
Compatibility issue when using frontend with BJ Lazy Load pluginhttps://wordpress.org/support/topic/compatibility-issue-when-using-frontend-with-bj-lazy-load-plugin/
-
Incompatibly with Sharify ?https://wordpress.org/support/topic/incompatibly-with-sharify/
-
Conflict with NS Google Sheets Connectorhttps://wordpress.org/support/topic/conflict-with-ns-google-sheets-connector/
-
Chart slow to load/freezeshttps://wordpress.org/support/topic/chart-slow-to-loadfreezes/
-
Plugin killed admin.ajax?https://wordpress.org/support/topic/plugin-killed-admin-ajax/
-
No Script insertinghttps://wordpress.org/support/topic/no-script-inserting/
-
Page request not found from some usershttps://wordpress.org/support/topic/page-request-not-found-from-some-users/
-
Conflicts with other Analytics pluginhttps://wordpress.org/support/topic/conflicts-with-other-analytics-plugin/
-
Wordfence and Google Analytics Dashboard conflicthttps://wordpress.org/support/topic/wordfence-and-google-analytics-dashboard-conflict/
-
gadwp.css admin class for onoffswitchhttps://wordpress.org/support/topic/gadwpcss-admin-class-for-onoffswitch/
-
GA General Settings Page Blankhttps://wordpress.org/support/topic/ga-general-settings-page-blank/
-
IE Zerif preloader Google Analytics Dashboard for WP=hang?https://wordpress.org/support/topic/ie-zerif-preloader-google-analytics-dashboard-for-wphang/