Google Analytics is a freemium software service that helps websites monitor traffic and identify trends in site visitor behavior that could, ultimately, impact marketing, conversions, revenue, and profits.
WordPress is the single most popular content management system with between 48 percent and 62 percent of the CMS market, according to BuiltWith, Opensource CMS, and W3Techs. Others estimate that WordPress powers at least one-in-five of the top 10 million sites on the web.
Ecommerce is also embracing WordPress as an estimated 250,000 sites use WooCommerce, the popular WordPress plugin that transforms the WordPress CMS into a functional ecommerce platform. WP eCommerce, another WordPress plugin, has been downloaded more than 2 million times since its release in 2006, and may have tens or even of hundreds of thousands of live ecommerce sites running on it.
Given the utility and popularity of Google Analytics and WordPress, it makes sense to demonstrate how quickly and easily the two solutions could be used together. What follows are the easy steps to install Google Analytics on any site using WordPress 3.9.1 or similar.
Get Google Analytics Tracking Code
Google has been known to change the Analytics navigation and terminology relatively frequently, and the company doesnâ€™t necessarily follow a versioning system. So it is possible that some users could have a slightly different interface than what is described here.
In general, open up Google Analytics. You will need to create an account, if you have not already done so. Once you have an account, navigate to the Admin page.
With the Admin page open look for the â€œTracking Infoâ€ link in the â€œPropertyâ€ column. Under â€œTracking Infoâ€ click â€œTracking Code.â€
Add the Tracking Code to WordPress
Open your WordPress installationâ€™s site administration. These instructions are for the form of WordPress (version 3.9.1) that you install on a server rather than the form of WordPress hosted at WordPress.com.
From the administration panel select â€œAppearanceâ€ and then â€œEditorâ€ to open up the theme editor. This editor should allow you to make changes to your WordPress theme files. If for some reason, you have trouble saving changes, check your server to ensure that the theme files may be overwritten.
With the WordPress editor page open, find the header.php (for our example, the tracking code is going in the header) under the Templates column and select it so that it is the active file.
In the editor, locate the closing head tag, which has a forward slash (/) before the word â€œheadâ€ inside of HTMLâ€™s characteristic brackets.
Add a couple of new lines and paste the Google Analytics tracking code into the header.php file just about the closing head tag.
Save the changes and update the file. Google Analytics should be installed. Try clicking around on the site a bit and checking out the Real Time analytics from the Google Analytics interface to ensure that everything is working correctly.
Beyond the Basics
This rather basic installation of Google Analytics will provide some information, but many, if not most businesses, will want to use more advanced features like custom variables or ecommerce tracking.
All of these features can be set up manually. As an example, check out Tim Wilsonâ€™s article â€œGoogle Analytics: 5 Custom Ecommerce Events to Track,â€ which explains what online merchants should track with Google Analytics and the code necessary to add some of these custom variables.
Also see Wilsonâ€™s articles â€œConfiguring Google Analytics, Part 1: Are You Taking Full Advantage?â€ and â€œConfiguring Google Analytics, Part 2: Advanced Capabilitiesâ€ to get the most out of Google Analytics.
There are also a couple of popular WordPress plugins that can help with Google Analytics.
The first is â€œGoogle Analytics for WordPressâ€ from developers Joost de Valk and Barry Kooij. This plugin provides an interface for WordPress users to set up a few custom variables like tracking a post author from a plugin options page. For sites that are using content marketing to promote transactions, this plugin can be very helpful. Also, if you install this plugin, you do not need to add Google Analytics tracking code, but rather have verify your Google Analytics account with the plugin and allow it to add the appropriate tracking code for you.
Businesses using WooCommerce may also want to consider using the â€œWooCommerce Google Analytics Integrationâ€ WordPress plugin, which can help track sales all the way back to the last click referrer.