How To Install Google Analytics In WordPress
4.8 (96.32%) 38 votes

Having your own website is an endeavor filled with both excitement and fear. Joy and confusion.

You ask yourself a lot of questions, and a lot of the time get very few answers.

  • Does my website look good?
  • What content should I add?
  • Why is no one commenting on my blog?
  • Do my parents even know I have a website?

Yes, in the beginning, there are a ton of things to fuss over, including letting your parents know about your presence on the web.

Once you iron out the details and your site starts to generate traffic, you can breathe a sigh of relief.

But only temporarily.

Why?

Because now your website is generating traffic, and that brings up a brand new set of questions.

  • Where is my traffic coming from?
  • Which posts and content do they enjoy the most?
  • Is my site too slow for the visitors I get?
  • Why haven’t my parents signed up for my newsletter?

Seriously, you should talk to your parents more often.

I can’t help you with them, but the other questions you ask are actually quite easy to address.

The answer is Google Analytics.

That’s it? Just Google Analytics?

Yep. Google Analytics.

And yes, it is a bit more involved than merely repeating the name, but for your website to take the next step, you should be adding Google Analytics.

We’re going to walk you, step-by-step through how to add Google Analytics to your WordPress site.

Ready? Let’s go.  

What Is Google Analytics?

What is Google Analytics

NOTE: Before you can install Google Analytics, you’ll need to create a business website or blog. If you’re thinking about eCommerce, read our guide on how to start an online store with WordPress + WooCommerce. We also have a step-by-step guide to start a store with Shopify.

Over 29.3 million websites use Google Analytics every day.

Knowledge is an incredibly powerful tool, and this is never truer than when starting your website or blog. Google gives you that knowledge by allowing you to track, monitor and analyze the traffic to your website.

Getting more eyeballs to focus squarely on your little piece of internet real estate ensures your website will continue to grow.

Google Analytics helps you achieve this in a myriad of ways:

Who are your visitors?

Knowing who your visitors are and where they come from are perhaps the top two pieces of data you need to expand your site effectively.

Google Analytics not only gives you where a user is from, but also tells you which browser they used, if it can support Flash, and even the resolution of the screen they’re using to view your web pages.

Unpacking that data helps you design a site with the end user in mind. The more you can tailor your site to meet the needs of your audience, the longer they’ll stay and the more page views you’ll receive.

How do your visitors find you?

Often, this is one of the central questions people ask about their web traffic, and for a good reason.

The analytics from Google gives you insight into which search engines are being used to push people your way. Usually, the answer is Google itself, but what if you receive unusually high hits from Bing or Yahoo?

What if it’s not a search engine, but links from another site or references from social media sites like Facebook, Twitter, or Pinterest?

Understanding how your audience finds you allows you to direct resources toward that search engine or platform and then increase the traffic.

When do they visit your website?

Google Analytics audience overview

So you know how they find you, but are you ever curious about the times they show up to your site? Are they coming when you publish new content? Do they come more during the day or evening?

The analytics shows this too, which helps you determine the best time to release new content. Or, if you started an eCommerce store, it can direct you when to launch a new product or promotion.

What do your visitors do on your website?

You mean, aside from hopefully pointing and clicking on as much as possible for as long as possible?

All kidding aside, there’s a lot more to it than you may think.

Google Analytics can show you the length of time a user stays on your site and where they are going while there. It can reveal your top landing pages, how long they stay on those pages, and whether they’re going to other pages from there.

Curious about the number of users that leave your site during their initial visit (the bounce rate)? Or maybe you need to have a clear understanding of which pages, posts or general content prove the most popular and get the most clicks.

The analytics Google provides gives you real data to ensure you spend your time and attention on the content that matters and getting rid of what doesn’t.

Successful websites are streamlined, targeted, and designed to meet and exceed the wants and needs of your audience.

Google Analytics can help make sure you attain that success.

Signing Up With Google Analytics

The two best things about Google Analytics (aside from all the amazingly helpful data you receive) is that it’s free and easy to add to your website.

First thing first though, you’ll need to set up an account. If you already have a Google account, great! Use that to get your analytics up and running.

If you don’t have a Google account, go ahead and set one up. Trust me when I say it makes everything a lot easier.

Sign up for Google Analytics

Once you’ve got that squared away, head over to the Google Analytics page to start the sign-up process.

Here you’ll see a three step overview and a sign-up box to the far right. Click Sign Up and use your Gmail credentials to get started.

Analyze your site's traffic in 3 steps

The next page is where Google collects info about the website you want to track. It’s pretty straightforward, but be sure to choose Website at the top and not the Mobile app.

Setting up your account

I want to point out that, should you have multiple websites that you’re wanting tracking data for, you can use the same Google account for different analytics accounts, up to 100.

From there you can also have 50 websites tied into one analytics account.

The hierarchy is really useful should you have multiple websites, particularly some that are personal versus ones that are business based. Google Analytics is very flexible in allowing you to organize your accounts to best suit your needs.

Getting back to the setup, once you’ve filled out the information on the New Account page, then click the Get Tracking ID button.

Analytics Tracking ID

Agree to the terms and then voila, you will see the tracking code to use for your website.

It’s helpful to copy the code, depending on your website and installation method.

Installing your tracking code

Your tracking code needs to be installed on each page of your website. Depending on your site and the method you use, this isn’t as tedious as it may sound.

With WordPress being one of the favorite website platforms, let’s lay out a few ways you can add the code to that site. But first, let’s examine how to install analytics for a few non-WordPress websites.

HTML Files

HTML Analytics code

If your website utilizes HTML, insert the code in front of the </head> tag on every page. Use a text edit program to add the code and then upload the file to your web host.

Website Builders: Shopify, Weebly, Wix, Etc

Shopify website builder Google Analytics installation

If you built a Shopify store (or another website builder like Wix or Weebly), it’s relatively simple to insert your tracking code. Head to your website’s Settings and add the code where appropriate.

Tumblr

Tumblr blogs also allow you to add Google Analytics. To do so, select Edit Theme in the top right corner and then add your ID as prompted in the Theme Options settings.

Just a few examples, but if your platform isn’t mentioned, or you’re having trouble finding where to add it to your site, a quick search on your platform’s help function should direct where you need to go.

That’s how universal Google Analytics has become.

Installing Your Google Analytics Tracking Code In  WordPress

As with most things related to WordPress, the key word here is plugin.

And there are lots of plugins you can use to get Google Analytics running on your WordPress site.

For the sake of clarity, I will show you the three most popular methods, two of which are via plugins.

MonsterInsights Plugin

MonsterInsights

In all honesty, your Google Analytics install on WordPress should begin and end with MonsterInsights. It is hands down the most widely applied analytics plugin and without question the simplest to use.

There are several versions, including a free plugin and then three different pay packages ranging from $39 a year (basic) to $199 a year (Pro).

The paid versions are useful if you have multiple business sites or are just looking for more in-depth advanced features. For most though, the free option will do the trick.

To get started, let’s get the MonsterInsights plugin installed and active on your WordPress site.

Click Plugins from your left sidebar and at the top of the plugin page select Add New, which will bring you to the Add Plugins page.

In the top right search bar type in MonsterInsights. It should be the first option available.

Add MonsterInsights plugin

Click Install Now and once the blue Activate button pops up go ahead and click that too.

MonsterInsights is now active in WordPress.

You should now see MonsterInsights added to your left navigation sidebar, listed as Insights.

To start the setup, hover over Insights and select Settings.

Authenticate Google account

From this page, click Authenticate with your Google account, which will take you the Google sign-in page. Sign in or if your account is already up, click Next.

Here you are prompted to allow MonsterInsights access to your Google Analytics. Select Allow.

Complete authentication

Finally, it asks you which profile to track. Choose your website and click the Complete Authentication button.  

This will take you back to WordPress.

And there you go. Like I said, simple.

What makes MonsterInsights such an excellent tool is you now have access to view your analytics reports directly from WordPress.

From the sidebar, select Insights, then Reports and everything you need is right there.

Insert Headers and Footers Plugin

As mentioned before, I strongly recommend the MonsterInsights plugin, but if you prefer a less robust option, then the Insert Headers and Footers plugin will work just fine.

The big difference is that with Insert Headers and Footers you cannot view the analytics reporting from your WordPress dashboard.

To install, follow the same method detailed above by navigating to the Add Plugin page and searching for Insert Headers and Footers.

Add plugin insert headers and footers

Follow the same steps for installation and activation.

Once complete, go to your Settings and select Insert Headers and Footers.

As mentioned earlier, this is the part where copying your Google Analytics code would prove helpful.

Paste the code in the Scripts in Header box and click the Save Changes button.

Scripts in Header

Okay, that was pretty easy too. But again, you’ll need to view your reports through the Google Analytics website and not on WordPress.

WordPress Theme Installation

So this is the AP Biology or Calculus option, and it’s one I’d only recommend for people who are handy with code use.

You can make the necessary updates two ways, through the functions file or by editing the header.php file.

For the functions file option, just add the analytics code to the file. The code will automatically update to every page in WordPress.

<?php
add_action(‘wp_head’, ‘wpb_add_googleanalytics’);
function wpb_add_googleanalytics() { ?>

// Paste your Google Analytics code from Step 4 here

<?php } ?>

For the header.php file, paste the analytics code directly after the <body> tag. Once complete, save the changes and load the file back to the server.

Google Analytics Reports

Now that you’ve set up Google Analytics on your website, you can look at all that data and unlock the secrets to your website’s success.

Having good data about what happens on your site help you see what’s working. And what isn’t. That way, you can make better decisions about engaging, monetizing and converting website visits into repeatable sales.

The reports themselves are easy to navigate and drill down into and as you’ll see, contain a mountain of information. You obviously won’t use everything here, but it is essential to familiarize yourself with what’s available and key in on the data that can help you the most.

There are five main reporting categories that Google Analytics tracks, each with numerous subcategories. They include:

Real-Time

Google Analytics Real-Time

Yep. Real-Time. As in right now, as it’s happening. Look at that, that web surfer from Texas just bought a t-shirt with an avocado on it and read your blog to boot.

This section of reporting is great if a website generates a ton of traffic and has a lot of continuous activity. Additionally, if you have an international audience, this will show you from where your traffic is surfing your site.

In real-time.

Audience

Are you starting a travel blog that only appeals to homebodies? If so, then you may want work out a few kinks in targeting your readers.

This is the place to do that. In the Audience reporting area, you’ll find out all you need to know about who is frequenting your website. Some of the subsections include stats about demographics, interests, location, and technology they are utilizing.

The answers to the questions about who your audience is and more importantly who they should be, get outlined here.

Acquisition

Google Analytics acquisition overview

Need to reassess that six-month campaign that netted one unique page view? We’ve all been there. That feeling that you’re just tossing cash out the window and into the black hole that is the internet.

Thankfully the Acquisition reports can, among other things, help get your marketing spend back on track.

This section of reporting includes details on how your visitors found your site. Search engines, social media, adword campaigns; the data here can help you direct resources to traffic generators that work and show which ones you may need to pull back from.

Behavior

Did your parents finally find your blog post about 101 Ways to Splice an Avocado with a Butter Knife? Did they spend five hours reading and trying to understand it?

Okay, so maybe the reports are not that specific, but the Behavior reports can tell you about your website’s content and how visitors interact with it.

Most page views, top blog posts, and even the pages where most of your audience bounces off your site are all found in this group of reports.

Conversions

Finally, conversions ties back to goal set-up, which I’ll get into shortly because it’s always good to have goals.

This series of reports give you a better idea if you are meeting your goals and where those conversions are coming from.

For example, if you get paid a $1.00 for each time someone reads your blog post about avocados, you can tailor your goals to see what part of the country you are generating the most income from or which source is driving you the most conversions.

I will cover how to review your reports shortly, but first, let’s take a look at some setup options that may prove vital to getting the most out of Google Analytics.

Google Analytics Tools

As powerful as the reporting is, there are a few tools available that can add even more dimension to how you use the analytic program.

Goals

Google Analytics goal setup

We touched on this briefly above in the Conversion setting as its something that can be of great benefit to you. By setting up goals within your Google Analytics program, you are indicating that specialized tracking is necessary to cover a specific action on your webpage.

An example of this would include generating a confirmation page after a sale or when somebody completes an opt-in or sign up form like a newsletter.

To set this up, head to the Admin page by following the link at the bottom of your left navigation pane, then click Goals under the View column. Once here, select New Goal.

New goal set up

On the Goal Setup page, you have a handful of Templates to select from, or you can choose Custom.

The templates include options for Revenue, Acquisitions, Inquiry, and Engagement.

Most of the time you will want to select Custom so you can tailor this specific to your site, but if you need something a bit more generic that suits your site well, the templates are still a good option.

For our demonstration, go ahead and select Custom which takes you to the setup page.

Goal setup configuration

Choose a name for your goal that is easy to remember, and under the Type prompt, choose Destination and then click Next Step.

Custom goal setup

When the next option, Goal Details, comes up type in the URL for your confirmation under the Destination heading and update the drop-down option to Begins with.

Custom goal description

You can also assign a value to the conversion goal should that apply.

Once done, you can select the Create Goal button.

If you have more than one goal, the setup will be the same for each. Google Analytics allows you to set up to 20 of these for each website. Just make sure it’s not arbitrary and its indeed something vital to your site’s success.

Site Search

Does your site have a search box?

If you answered yes, then Google Analytics has a neat feature to help track what visitors look for when they use your site’s search function.

The setup is similar to the goals procedure, but with the search tool, you’ll need a bit of info directly from your website.

So first, head to your website and perform a search through the search box.

In a separate tab, go the Google Analytics site and navigate to Admin, then View, and then View Settings.

Admin view settings

At the bottom of the page the last option is Site Search Settings, and underneath that is Site Search Tracking. The default for this is toggled off, so go ahead and click the button to turn it on.

Site search settings

You see an additional option pop-up called Query Parameter.

Back on your website, where you performed the search, review the URL and find the query parameter, which will typically be either a q or an s.

Query parameter

Whichever letter it is, enter it in the query text box on the analytics page and click Save. Google Analytics will now start collecting your websites search data.

Adding Accounts

I can tell you’re at the point where you want to know how to add even more accounts to Google Analytics. I’m so glad you asked.

From your Admin menu, head to the Account column and from the drop-down menu click Create New Account (note this also shows you the number of accounts you’re using from the 100 possible) and follow the prompts.

Admin create new account

You can also add a new website to your account from the Property column. Simply select Create New Property (website) from the drop-down (here it keeps the tally of your 50 possible sites) and again follow the prompts as outline prior.

Create new property

Viewing Google Analytics Reports

So you may have noticed the report overview earlier, then went into a few setup options, and are now back to the reports to cover how to view them.

With Google Analytics, that is the natural order of things.

Let me explain.

For the first 24 to 48 hours, there will be little to no information available for you to review. Initial data collection will take time to ramp up, and you’ll want to spend this period setting paraments like search tracking or your goals.

Also, the first few days of data could be pretty sparse, depending on your website’s overall traffic numbers. That’s perfectly okay.

It’s hard to glean usable information from a handful of visits and patience will be important your first few weeks utilizing Google Analytics.

Now, if the traffic to your site was robust before adding analytics, you’ll still have the same couple of days lag time. But by the end of week one, you should have plenty of information to discern what’s happening on your website.

Google Analytics overview reports

As mentioned earlier, Google Analytics reports are broken down into five categories: Real-Time, Audience, Acquisition, Behavior, and Conversions.

Real-Time contains five separate reports. Audience has close to 26 reports. The Acquisition section has 20.  Behavior includes 17. Conversion comes in with 13 reports, respectively.

That’s over 75 standard reports. That is a lot to digest.

Did I mention you can also create custom reports? Yeah, there’s that too.

The good news is that Google has made all of these reports easy to navigate and their data easy to identify.

Report Features

Regardless of the report, Google has done well in keeping them all consistent with a similar look and feel.

The reports page always pulls up your overall data. If you have only one account and one website, no problem. If you have multiple sites though and want to drill down into each one, just click All Accounts link in the top left corner and select the account you want to view from the drop-down.

Report features

You can toggle between reports using the left navigation pane.

Once in a report, hovering your mouse over individual data points or headings helps provide more details or definition as to what you’re reviewing.

In the upper right, you can customize date ranges or compare one date range to another.

The bottom of some reports will provide top ten data points and links to others with more in-depth metrics.

For example, if you are reviewing the Audience Overview report, scroll to the bottom and select Operating System from the list of links.

The sub-window to the right will pop up with a general overview of the top ten points for Operating Systems. For full details, click the View Full Report link, and you will jump to the breakout for Browser & OS data.

View report breakdown Browser & OS

Saving, Sending, and Intelligence

Admittedly, clicking multiple times to get to the report you want can be a hassle. Thankfully you can save your favorite reports, and their configurations, for easy access in the future.

To do so, navigate to a report you frequently use and click Save from the right toolbar just above the date range.

Save report

Name the report and click OK.

The report saves under Customization, Saved Reports in the left navigation pane.

You can also export reports as a PDF, Google Sheets, regular Excel file, or CSV file by selecting the appropriate option in same upper right toolbar.

From here you can also share your report, by clicking the Share button and filling out the email prompt.

Also in this toolbar is an option called Intelligence. A handy and very practical tool, it allows you to ask questions and cut right to the answer.

For example, when you click Intelligence, a search option expands from the right side of the screen.

Type in a question, such as “What are the top pages by state?” and the function provides you a quick overview and link to the report showing further details.

There is additional functionality here called Insights, which combs through your data and helps you to see and understand certain trends or details you may otherwise miss.

An example here would include if your audience in a once user rich state has leveled off or is dropping, this would allow you take steps to address that decline.

Custom Reports

In addition to the vast array of standard reports, Google Analytics gives you the option to combine your top data points into customized versions specific to your needs.

Another option includes creating a customizable dashboard which allows you access to your information through a dashboard view.

Both of these are straightforward to set up and can be done so by visiting the Customization option on your navigation pane.

Select the corresponding option and then click the Create button for the dashboard or +New Custom Report in Custom Reports.

With the custom reports option, you can also choose ready-made reports by clicking Import from Gallery and then searching through the options to see if any fit your needs.

Have Fun in the Sandbox

I know what you’re thinking.  

And yes, it is a lot to absorb. Particularly for those who are just getting started and taking the initial steps to learn more about all of the information your website produces.

But instead of being overwhelmed look at this an opportunity to delve head first into the next phase of growth for your website.

All of this data won’t change things overnight, nor will it make you or your site the next Amazon or Facebook. What it will do is make you a smarter, more informed administrator.

Targeted marketing.

Meaningful promotions.

Higher page views.

Smarter spend.

A bigger audience.

All of these are the result of knowing where you are and where you need to go. Google Analytics can help get you there.

So play around in the sandbox.

View every report and zero in on the ones that work for you.

Don’t shy away from the Admin area and assume your first configuration and setup is your last configuration and setup.

And finally, be patient with all the analytics has to offer. Understand your data and then apply those findings in a meaningful, impactful way.

Conclusion

If you have a website, blog, ecommerce site, or heck, even all three, visitor data is an invaluable resource for growing your brand. Knowing who your visitors are, where they come from, and what they do when they get to your site is paramount to ensuring your sites continued success.

Google Analytics can help get you the knowledge you need by providing you data that looks deeper than just clicks and page views.

A few minutes of setup and then committing the time to familiarize yourself with the program are small investments to make considering how big the rewards could be.

And who knows, you may even one day capture that most elusive of audiences, your parents.

Dashboard custom reports
How To Install Google Analytics In WordPress

Written by Alex Jasin

Last Updated: March 20, 2018