view at full size
You can use the WordPress default search parameter to configure site search in your Google Analytics profiles.
If you enter a search term into the default search widget on a WordPress site, you’ll see that the URL of the search results page contains “s” as the parameter name for the search term entered.
Site search tracking in Google Analytics is very straightforward and can yield valuable insights about user intent. To track the usage of site search, you would need only to enter “s” as the Query Parameter value within the Site Search Settings for your profile/view.
You can configure site search tracking for non-Wordpress websites in the same way; you would just need to identify the site search parameter in the URL of your search results page and specify accordingly in your profile/view settings.
view at full size
You can manually add the Google Analytics code tracking to header.php in WordPress.
A recent post discussed free WordPress plugins for Google Analytics. Several of these plugins are easy to use and flexible, but another option for tracking WordPress is to add the Google Analytics tracking code directly into header.php.
To do this, you can open header.php in the editor and insert the tracking code just before the </head> tag. You can also add any customizations that you may need, such as for cross-domain tracking or Enhanced Link Attribution.
While a plugin may meet your needs in most cases, it’s good to have the flexibility of code editing when you might need it.
The extensibility of the WordPress platform and the contributions of the WordPress developer community allow us to add endless capabilities to WordPress sites, usually with minimal setup, and often for free. Among available plugins are several that inject the Google Analytics tracking code into your pages.
As a minimum for configuration, you’ll need to specify your UA number, or Google Analytics Property ID, which you can access within the Google Analytics interface for your property, either on the admin screen or within the tracking code provided.
If you’ll need to configure cross-domain or subdomain tracking, make sure that the plugin permits the necessary changes to the tracking code.
Apart from installing the tracking code, some of the Google Analytics plugins allow you to include a Google Analytics dashboard on your WordPress site, either for yourself as administrator or for your visitors.
If you don’t find a plugin that allows sufficient customization of the Google Analytics tracking code for your needs, you can always add customized code to your pages by manually editing the WordPress include files – more on this in an upcoming post.