How to Manually Add the UA Tracking Code to MonsterInsights

Do you need to manually add the UA tracking code to your MonsterInsights plugin? This guide will show you how.

Step 1: Install and activate the Code Snippets plugin in WordPress. For detailed instructions on how to install a WordPress plugin, see the guide: How to Install a WordPress Plugin – Step by Step for Beginners.

Step 2: Navigate to Snippets > Add New.

Step 3: Add a descriptive title such as Manual UA Code MonsterInsights.

Step 4: Add the following code to your snippet:

 * Manually set a custom UA code in MonsterInsights.
 * @param string $ua The current UA code.
 * @return mixed
function monsterinsights_custom_manual_ua( $ua ) {
	$ua = 'UA-123456-1';// Replace this with you UA code.
	return $ua;
add_filter( 'monsterinsights_get_ua', 'monsterinsights_custom_manual_ua', 15 );

Step 5: Be sure to replace that UA code with your own Google Analytics UA code. If you aren’t sure what your UA code is, please see the first step in our guide: How to Fix Wrong Google Analytics Profile Selected in Settings.

That’s it! Now you know how to manually add the UA code to your MonsterInsights plugin.