February 20, 2022

Installing Google Analytics on your WordPress blog gives you access to a powerful range of data and statistics that can help you understand more about your audience. Many website owners use Google Analytics as a way to monitor traffic numbers of people visiting the site, but there is so much more information you can glean from such powerful metrics.

When you log into your Google Analytics account you’re able to see the geographic locations of your site’s visitors. Your dashboard can show you what keywords were used to find your site and which sites referred your visitors.

Google Analytics allows you to determine what pages they landed on when they first arrived on the site and which pages they viewed during their visit. You’re also able to see where your visitors were when they left your site, giving you valuable insight into what might be causing you to lose sales or conversions.

With so much valuable information on offer, it should be obvious why installing Google Analytics into your WordPress site is a good idea. Fortunately, there are several ways to install the code onto your blog.

Create Your Google Analytics Code

If you already have a Google account, such as a Gmail account, you can log in as you normally would. Your existing account information is valid for almost every application available with Google, including Analytics. If you don’t have an account, go ahead and create one.

Once you have logged into your account, head over to the Google Analytics page (google.com/analytics/). Click the link at the top of your dashboard on a tab labelled ‘Admin’.

Inside your Admin page are three columns. The middle column is titled ‘Property’. Look for a link that says ‘Tracking Info’. If you click the link, a dropdown box will show you several options.

Click the link that says ‘Tracking Code’. A new sub-section will open showing your unique Tracking ID and the tracking code you need to insert into your WordPress blog.

If you intend to paste your tracking code directly into your HTML code, you need to copy the entire section of code within the box shown. If you’re using a plugin to add Google Analytics, you will need to take note of your Tracking ID.

Adding Google Analytics Code Directly into Your WordPress Header

Right above the tracking code in your Google Analytics account is a line asking you to copy and paste it into every page of your website that you want to track. If you still had a static HTML website, you would be required to paste the entire code manually into the correct section of code within every individual page.

Fortunately, WordPress makes the task much easier for you. You’re able to paste the code into your WordPress site once and it will report statistics and information from every page.

Log into your WordPress dashboard and click on the Appearance link. A separate menu will pop open beside it, so scroll to the final link on the list labeled ‘Editor’.

You’ll be taken to a new page showing the stylesheet for your blog. On the right-hand side of the page you’ll see a long list of template links. Scroll down until you find the header.php template and click the link.

If you’re familiar with HTML coding, you can scroll through the lines of code until you locate the closing head tag. It looks like this:

If you struggle to follow HTML coding, you can cheat by pressing Control-F. A search bar will open on your browser. Type into the browser search and it should take you directly to the line of code you want.

Place your cursor before the closing head tag and press enter a couple of times to add some space between the previous lines of code. Then paste the entire Google Analytics code you got from your account.

When you’re done, click the blue button at the bottom of the code that says “Update File” and your tracking code will be added to every page of your site. Your site’s analytics should start showing in your Google dashboard within 24 hours.

Adding Google Analytics Code Directly into Your WordPress Footer

Google’s instructions recommend pasting your Analytics tracking code directly into the header.php file. However, WordPress recommends pasting the code into the footer.php file.

In your WordPress dashboard, navigate to the Appearance link on the left-hand side. Click on the Editor link from the dropdown box. Scroll down through the links on the right-hand side of the page and locate the footer.php file. Click the link and a new page showing your footer file code will open.

Scroll through the code until you locate the closing body tag. It looks like this:

Place your cursor before the closing body tag and press enter a couple of times to add some space between the previous lines of code. Then paste the entire Google Analytics code you created within your account. When you’ve done this, click the blue button at the bottom of the code that says “Update File” and your tracking code will be added to every page of your WordPress theme.

Adding Google Analytics Code via a WordPress Plugin

If you’re not comfortable messing with your site’s HTML code directly you can install a plugin that will add the Google Analytics code into the correct locations for you. There are lots of different plugins you can install, including:

Once you’ve installed the plugin you want to use, log into your site’s dashboard. Some plugins will add a new link to the options shown down the left-hand side of your dashboard navigation. Others may appear within the Settings navigation option.

Depending on the plugin you’ve chosen, you should only need to enter your Google Analytics ID into the required field. When you’re done, save your changes and Google should begin showing your site’s stats within 24 hours.

Note: The options in this article relate to self-hosted WordPress sites only. If your site is hosted on the free WordPress.com platform you won’t be able to use Google Analytics.

Related Posts

Page [tcb_pagination_current_page] of [tcb_pagination_total_pages]