Two ways to add Google Analytics to WordPress

Learn how to add Google Anlaytics to your WordPress website

Website visitors are real people, with different kinds of personalities, and different kinds of interests. In order to maximize your potential to succeed, you must learn about the behavior of your visitors and what makes them attracted to your website in the first place, so that you can take that insight and capitalize on it in the future, one of the best free methods for tracking your site users is by using the Google Analytics tracking tool.

Google Analytics
Google Analytics

At the very core level, Google Analytics provides you with daily/weekly/monthly/yearly statistics of your website traffic in terms of the number of visitors that you’re attracting, where these visitors are coming from (both countries, and website sources), and how much time they’re spending on each page they’re visiting. In the past, it used to be possible to track the keywords that people used to access your content, but since 2011 Google has decided not to display this data anymore. Some of it can be recovered through Google Webmaster Tools.

Adding Google Analytics tracking code by modifying the footer.php

Once you have created a new account with Google Analytics, and have created a “New Property”, it’s time to grab the tracking code and add it to your WordPress website so that you can start tracking your visitors. Start by opening up the Google Analytics site and find the tab called Admin in the top menu.

Google Analytics Admin
Google Analytics Admin

After you’ve found the admin tab, select your newly created property and click Tracking Info -> Tracking Code which will take you to a page that contains your tracking code.

Google Analytics Tracking Code
Google Analytics Tracking Code

At this point, all that’s left to do is to copy the tracking code and insert it into your WordPress theme that you’re using. One way to do this is by editing the footer.php file, which you can do by using your own editor on your computer and then uploading the edited file through an FTP client, or you can edit the file directly through the Theme Editor in WordPress.

(We don’t encourage leaving your files with editable conditions, since it is a security risk, but for this demo we will use the theme editor to show where to put the code. WordPress security is serious business!)

Theme Editor GA Tracking Code
Theme Editor GA Tracking Code

As you can see in the screenshot above, you have to open the editor through Appearances => Editor and select the footer.php file from your current theme. After that, insert the Google Analytics tracking code where it makes sense, hit the save button and refresh the site.

(You might have to clear the cache if you’re using a caching plugin.)

After this you can go back to the Google Analytics site, select the website you’re now tracking stats for, and within the control panel there will be an option to see Real Time stats, just to make sure that you’re at least tracking yourself.

Warning: In general it’s not a good practice to modify the original theme files of your theme because these changes will be lost after theme updates. That means if you want to follow best practices, you should create a child theme to modify your theme files or use a plugin to add your Google Analytics tracking code. Some WordPress themes also have integrated options to easily add the tracking code.

Adding Google Analytics by using a WordPress Plugin

The first technique is a little bit technical, but it’s nothing difficult. If you find it unappealing, perhaps it’s worth trying out a simple Google Analytics plugin that will take care of everything by itself (but not the creation of a GA property), so here’s a simple solution.

Google Analytics by Yoast
Google Analytics by Yoast

Google Analytics by Yoast has been downloaded millions of times, and more than a million websites have this plugin active right now. It’s so practical that all you have to do is install the plugin and select the “Connect to Google Analytics” option from the plugins option panel and you will be done in less than a few seconds.

If for some reason this plugin does not work for you, there are at least a hundred different alternatives available on the public WordPress Plugin Directory.

Alternatives to Google Analytics

Each analytics tool is different, some offer premium features at no cost, while some offer unique features that can’t be found elsewhere. If Google Analytics doesn’t resonate with your current ideologies, here are three good analytics alternatives that you may want to take for a spin.

  • Piwik — Piwik is also known for its real-time tracking features, it’s also known for the in-built tracking features that allow you to track each of your page elements individually, such as text ads, or banners. You can self-host it which means that you will always be in charge of what’s happening.
  • Kissmetrics — Kissmetrics is a great analytics tools for small businesses and anyone who is trying to sell anything on their website. Kissmetrics will provide you with the insights and reports that show you where your sales are leaking and what you can do to fix those leaks.
  • Woopra — Woopra understands how important it is to know your customers, and so provides an analytics platform that goes in-depth about each user personally, allowing you to track their every step on your website: including what they’re reading, purchasing, or which pages they’re spending the most time on.

Any analytics tool that understands the evolution of marketing and the web in general is going to be able to provide features that can help you to understand the way your website really works, and give you real insight into the lives of your visitors so that you can connect with them on a new and exciting level.

Share this with your friends

Leave a Comment

Your email address will not be published.


*