, ,

Connect Google Analytics To Your WordPress Site

Google Analytics is a powerful analytics service that provides reports on website traffic, page views, bounce rate, referral sources, user behavior, website conversions and goals, and more. This information is critical to the growth and improvement of your website, your ongoing marketing strategy, and the expansion of your brand.

Google Analytics is by far the most widely used and most popular website analytics tool available and because it’s free, you owe it to yourself to make sure you have Google Analytics connected to your WordPress website.

Here are three options to connect a WordPress website and Google Analytics:

  1. Add Google Analytics Directly To Your WordPress Theme
  2. Add Google Analytics To WordPress With The Insert Headers and Footers Plugin
  3. Connect WordPress And Google Analytics With MonsterInsights


OPTION 1: Add Google Analytics Directly To Your WordPress Theme

You can easily add Google Analytics to your WordPress site without a plugin through the header.php file or the theme functions file. Just be sure to perform a complete site backup before editing your theme files.

To add Google Analytics to your site using the header.php file:

  1. Login to your Google Analytics account and copy the tracking code for the website you’re working on. You can find the tracking code under Admin > Tracking Info > Tracking Code.
  2. Open the header.php file for your WordPress website and paste the tracking code directly after the <body> tag and click update.

Or, to add Google Analytics to your site using the functions file, add the following code to your theme’s functions.php file, inserting your tracking code:


<?php
add_action(‘wp_head’, ‘wpb_add_googleanalytics’);
function wpb_add_googleanalytics() { ?>
// Paste your Google Analytics tracking code here
<?php } ?>


OPTION 2: Add Google Analytics To WordPress With The Insert Headers and Footers Plugin

If you prefer to add Google Analytics to your site through a more straight-forward plugin that doesn’t have you editing your theme files, you can use the plugin Insert Headers and Footers, a simple plugin that lets you insert code like Google Analytics, custom CSS, Facebook Pixel, and more to your WordPress site header and footer.

Here’s what you need to do:

  1. Install and activate the Insert Headers and Footers plugin
  2. Login to your Google Analytics account and copy the tracking code for the website you’re working on
  3. Open the settings page for the plugin
  4. Paste your Google Analytics tracking code into the “headers” section
  5. Save your changes

Tip: Remember, to Backup your WordPress site before installing any new plugins.


OPTION 3: Connect WordPress And Google Analytics With MonsterInsights

MonsterInsights is another WordPress plugin that connects Google Analytics with your WordPress website, but MonsterInsights offers advanced tracking configuration and adds a Google Analytics dashboard right into your WordPress site admin area so you can see real-time stats and data about your website and visitors without ever leaving your website.

Here’s how to get started:

  1. Install and activate the Google Analytics by MonsterInsights plugin
  2. Open the settings under the new Analytics menu item in your WordPress admin bar
  3. Connect your Google Analytics account in one of two ways:
    • Authenticate the plugin with your Google account — If you are signed in to your Google Analytics account, click the Authenticate with your Google account and follow the instructions.
    • Manually enter your UA (User Account) code — Check the Manually enter your UA code box and paste in your Google Analytics tracking code with your UA number
  4. Save your changes

Quick Reminder

Google Analytics will only have data about your website from the time it was connected to your website and you may not see that data right away. Give Google about 24 hours to crawl your website and soon you’ll begin seeing data about your website traffic, where it’s coming from, what visitors are doing on your site, and how long they stay.

Over time this collection of data will allow you to make informed, educated decisions about the management of your WordPress website, the improvement of your WordPress website, your blog content strategy, your search engine optimization strategy, and more.

Need A Faster Site?

With AlpineWeb’s Managed WordPress Hosting, you can focus on getting insights with Google Analytics while we take care of backups and automatic updates for you!