Categories
Web Development WordPress

How to Hard-Code a UA String for the Google Analytics for WordPress Plugin

If you want to define a Google Analytics “UA String” while using Yoast Google Analytics¬†plugin for WordPress.

Add the following to your theme’s `functions.php` file:

add_filter( 'option_Yoast_Google_Analytics', 'custom_ua_string_filter');

function custom_ua_string_filter($options = array()) {
	$options['uastring'] = 'UA-########-#';
	$options['manual_uastring'] = true;
	return $options;
}

For users of WordPress Multisite, this will allow you to pre-configure new blogs with the same UA string.

By Zack Katz

Zack Katz is the creator of GravityView and the President of Katz Web Services. He lives in Denver with his wife and cute beast of a cat.