There are several options available when installing Google Analytics on your WordPress website. Before proceeding with any of the below options you will need to have a Google Analytics account setup along with the tracking ID for your website.
Option 1: Edit Theme Template
Since you have full access to your website’s theme template files via the WordPress dashboard you can add the tracking code to your website directly.
- Login to your Google Analytics account.
- Click Admin.
- With the desired Property selected click Tracking Info.
- Copy the provided tracking code e.g.
(function() {<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-Y']);
_gaq.push(['_trackPageview']);
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();
</script> - Login to your WordPress website.
- From your WordPress Dashboard select Appearance > Editor from the left menu.
- Click Header (header.php) from the Template files listed on the right.
- Paste the Google Analytics tracking code just before the closing
</head>
tag.
Option 2: Use a Plug-in
The other option is to use a plug-in to install Google Analytics on your WordPress account for you. There are numerous plug-ins available to do this, each with there own features.
We use Google Analytics Dashboard for WordPress which outputs statistics in the WordPress dashboard. For more information about this plug-in visit our recommended WordPress plug-in page for Google Analytics Dashboard for WordPress.