• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Matt Doyle | Elated Communications

Web and WordPress Development

  • About Me
  • Blog
    • Design & Multimedia
      • Photoshop
      • Paint Shop Pro
      • Video & Audio
    • Online Marketing
      • E-Commerce
      • Social Media
    • Running a Website
      • WordPress
      • Apache
      • UNIX and Linux
      • Using FTP
    • Web Development
      • HTML
      • CSS
      • JavaScript
      • PHP
      • Perl and CGI Scripting
  • Portfolio
  • Contact Me
  • Hire Me
Home / Blog / Running a Website / Set Up Google Analytics for Your Website: A Beginner’s Guide

Set Up Google Analytics for Your Website: A Beginner’s Guide

2 December 2016 / Leave a Comment

Google Analytics setup tutorial

Want to set up Google Analytics on your website? You’ve come to the right place!

Everyone says Google Analytics is fantastic for understanding your visitors, website, and online biz. But how the heck do you get started with it?

Maybe you had a go at setting up Google Analytics, but couldn’t get it working properly with your site. Or maybe it all seems too hard to even begin!

If this sounds like you, I’ve got you covered. In this tutorial I walk you, step by gentle step, through creating a Google Analytics account, linking it to your website, and testing it all works. You’ll also learn about stopping pesky Google Analytics spam, and find out what to do once you’ve set up Analytics with your site.

By the time you’ve finished reading, you’ll understand the whole setup process and you’ll feel like an Analytics pro!

To keep things simple, I focus on linking Google Analytics with WordPress. If you don’t have a WordPress site, don’t worry — most of this tutorial still applies, and I’ve also included links that explain how to set up Analytics with Joomla, Wix, Weebly and more.

Ready to set up your Analytics? Let’s go!

Step 1: Sign into Google Analytics

To use Google Analytics, you need a Google Account. If you’ve ever used Gmail, Google+, or any other Google service, you already have an account. If not then go ahead and set one up now, then come back here.

Follow these steps to sign into Google Analytics and begin the setup process:

  1. Go to the Google Analytics website.
    Visit www.google.com/analytics/ in a new browser window.
  2. Sign into Google Analytics.
    Click the SIGN IN link in the top-right corner, then click Analytics in the pop-up menu that appears:

    Google Analytics: Sign In link
    Start by clicking the SIGN IN link on the Google Analytics homepage…

    Google Analytics Sign In: Analytics link
    …then click the Analytics link.
  3. Sign into your Google Account.
    If you’re not already signed into your Google account then enter your email address, click Next, enter your password, and click Sign In:

    Sign into Google Account
    Sign into your Google Account if necessary.
  4. Begin the Analytics signup process.
    A page appears explaining the setup process. Click Sign up to continue:

    Google Analytics setup process
    Click the Sign up button to create your Analytics account.

Step 2: Enter your account details

Once you’ve clicked the Sign up button in the previous step, you’ll see a New Account page appear. Here’s where you enter the details of your Google Analytics account and website:

Google Analytics: New Account page
In the New Account page, fill in the details of your account and website.
Don’t worry about entering the wrong things in this form — you can change all of these settings later in the Google Analytics admin.

Here’s how to fill in this form:

  • Website / Mobile app: Google Analytics lets you track visits to your website, as well as usage of mobile apps. Since you want to track your website traffic, make sure Website is selected.
  • Account Name: This will usually be the name of your business. You can track several websites (known as properties in Analytics-speak) under one account, but in this tutorial you’ll just track one site.
  • Website Name: Enter the name of your website here.
  • Website URL: Enter the URL (web address) of your website’s homepage — for example, www.example.com. If your website uses HTTPS — which is usually a good idea — then click the button to the left of the URL text field and change http:// to https://.
  • Industry Category: This setting is optional. If you set it to your biz’s industry then it helps Google tailor their reports, communications and educational tools to your needs. It doesn’t affect your visitor tracking at all.
  • Reporting Time Zone: Pick your time zone to make sure the reports use the correct times for your location.
  • Data Sharing Settings: These settings control what Google does with your Google Analytics data. They’re all selected by default, but feel free to deselect any of them. You can always turn them on again later.

When you’ve entered all your details and reviewed your data sharing settings, scroll down and click the Get Tracking ID button:

Google Analytics: Get Tracking ID button
Once you’ve filled in the form, click Get Tracking ID to continue.

You’ll see a popup containing the Google Analytics terms of service. Select your country from the drop-down menu, then click the I Accept button to accept the terms:

Google Analytics terms of service
Review the terms, then click I Accept to accept them.

Step 3: Insert the tracking code in your website

Once you’ve agreed to the terms, Google Analytics takes you to the Tracking Code admin page for your property (website):

Google Analytics: Tracking Code admin page
The Tracking Code admin page contains two important things: the Tracking ID and the JavaScript tracking code for your website.

There are two important things on this page:

  • Your Tracking ID: This is a unique string of text that identifies your Google Analytics account and website. In the screenshot above it’s UA-XXXXXXXX-1, but your Tracking ID will contain digits instead of the Xs.
  • Your tracking code: This is the code in the box under Website tracking. It’s a snippet of JavaScript code that you need to insert into every page of your website, so that Google Analytics can track your visits.

Keep this page open, as you’ll need to copy your Tracking ID or tracking code in a moment.

If you accidentally close this page, you can get back to it by visiting analytics.google.com, signing in if necessary, then clicking the ADMIN menu option, followed by Tracking Info > Tracking Code in the PROPERTY column.

Here’s how to insert the tracking code on your WordPress site, as well as on other types of site:

Method A: Insert the code using a WordPress plugin

This is the easiest way to install the tracking code in WordPress.

I’m assuming you’re running your site using WordPress.org. If you’re using WordPress.com, you can only use Google Analytics if you have the Business plan. Here are the instructions for setting it up.

There are many free WordPress plugins that automatically insert the tracking code into every page of your site. I like the GA Google Analytics plugin because it’s simple to use.

Follow these steps to install the plugin and insert your tracking code:

  1. Log into your WordPress admin.
    Open a new browser tab. Visit your WordPress admin URL, enter your admin username and password, and click Log In.
  2. Search for the GA Google Analytics plugin.
    In the left-hand admin menu, choose Plugins > Add New. In the Search Plugins box at the top right of the page, type ga google analytics and press Return.
  3. Install the plugin.
    Find GA Google Analytics in the search results, and click Install Now to install the plugin:

    Installing the GA Google Analytics plugin in WordPress
    To install the GA Google Analytics plugin, search for it in the Search Plugins box, then click its Install Now button.
  4. Activate the plugin.
    After a short while, the Install Now button should change to say Activate. Click the button to activate the plugin. In a few seconds, you’ll see the message Plugin activated appear at the top of the page.
  5. View the settings page.
    In the left-hand menu, choose Settings > Google Analytics to display the plugin’s settings page:

    GA Google Analytics settings page
    Choose Settings > Google Analytics in the left-hand menu to view the plugin’s settings page.
  6. Display the settings.
    Click the Plugin Settings header in the settings page. It expands to reveal the settings:

    WordPress: GA Google Analytics plugin settings
    Click the Plugin Settings header in the page to reveal the settings.
  7. Enter your Tracking ID.
    Switch to your Google Analytics browser tab again. Select your Tracking ID in the Google Analytics Tracking Code admin page that you kept open earlier. Choose Edit > Copy to copy the Tracking ID, then switch back to your WordPress browser tab and click the box next to GA Property ID. Choose Edit > Paste to paste your Tracking ID into the box:

    Tracking ID in Google Analytics Tracking Code page
    Copy your Tracking ID from the Google Analytics Tracking Code page…

    GA Google Analytics Tracking ID
    …then paste it into the GA Property ID box in the GA Google Analytics settings.
  8. Enable Analytics and Universal Analytics.
    Select both the Enable Analytics and Universal Analytics checkboxes to turn on the tracking. (Universal Analytics is the latest version of the Google Analytics tracking code; you almost definitely want to use it.)

    GA Google Analytics: Enable Analytics and Universal Analytics
    Select the Enable Analytics and Universal Analytics options.
  9. Turn off tracking for your own visits (optional).
    Google Analytics tracks your own visits to your site, just as it tracks your visitors’ visits. If your site doesn’t get much traffic — and you visit your own site a lot — then your own visits can distort your Google Analytics reports quite a bit! To help with this, you can select the Disable GA on the frontend for Admin-level users checkbox. This stops the Google Analytics tracking code being inserted into pages when you view your site. (Just make sure you’re logged in as a WordPress admin user whenever you visit your site!)

    GA Google Analytics: Disable GA on frontend for admin users
    Select this option to turn off Analytics tracking when you’re logged in as an admin.
  10. Save your changes.
    You can ignore all the other settings for now. Click the Save Settings button to save your changes:

    GA Google Analytics: Save Settings button
    Once you’re finished, click Save Settings to save your Analytics settings.

All done! The plugin should now insert your Google Analytics tracking code into every page of your site. You can skip ahead to Step 4 below!

Method B: Copy and paste the code into your WordPress theme settings

If you don’t want to install a plugin just to insert your Google Analytics tracking code, you can usually insert it manually into your pages by copying and pasting the JavaScript tracking code into your WordPress theme’s header. How you do this varies slightly depending on the theme you’re using. Here’s how you do it if your site uses a Genesis theme (make sure you back up your site first!):

  1. Log into your WordPress admin.
    Open a new browser tab and visit your WordPress admin page. Enter your admin username and password and click Log In.
  2. Access the theme settings.
    In the left-hand WordPress admin menu, choose Genesis > Theme Settings:

    Genesis theme settings
    Choose Genesis > Theme Settings (or the equivalent option for your theme) in the left-hand menu to bring up the theme settings.
  3. Find the Header Scripts box.
    Scroll down the page until you see the Header Scripts box. It’s inside the Header and Footer Scripts section.
  4. Copy and paste the tracking code.
    Switch to your Google Analytics browser tab. Click the JavaScript tracking code in the box under Website tracking to select it, then choose Edit > Copy. Switch back to your WordPress browser tab, click the Header Scripts box, and choose Edit > Paste to paste the tracking code into the box:

    Google Analytics: Copy tracking code
    Copy your tracking code from the Google Analytics Tracking Code page…

    Genesis theme: Paste tracking code
    …and paste it into your theme’s Header Scripts box.
  5. Save your changes.
    Click the Save Changes button at the bottom of the page to save your tracking code.

If you’re not using a Genesis theme then your admin page will look different, but there is usually a box called something like Header Scripts or <head> Code somewhere in the theme settings.

If you can’t find this setting in your theme, you can try pasting the JavaScript code directly into the theme’s header.php file. (If you go this route, make sure you create a child theme first to avoid your changes being overwritten when you update the theme.) To edit your header.php file, choose Appearance > Editor in your WordPress admin and click the header.php template in the right column:

WordPress: Editing the theme header
To edit your theme’s header file, choose Appearance > Editor in the left-hand menu, then click the header.php link on the right.

Make sure you paste the code just before the </head> tag in the header:

WordPress: Pasting Google Analytics tracking code into header
Paste your tracking code just before the </head> tag.

Once you’ve pasted the code, click the Update File button below the editor box to save your changes.

How to insert the code into other types of site

No WordPress? No problem! Here’s how to add your Google Analytics tracking code to other website platforms:

  • Joomla: As with WordPress, there are tons of free Google Analytics plugins available that insert the tracking code on your site pages. Asynchronous Google Analytics is a good one.
  • Tumblr: Some Tumblr themes have an option to paste in your Google Analytics Tracking ID; with other themes you need to copy and paste the JavaScript code just before the </head> tag as described in Method B above. Here are the instructions you need.
  • Squarespace: Just paste your Google Analytics Tracking ID into Squarespace’s Google Analytics Account Number box. Full instructions here.
  • Wix: You need to have a Wix Premium Plan with your own domain. Then you paste your Google Analytics Tracking ID into the Google Analytics Code box under the Analytics tab. Here’s how to do it.
  • Weebly: Log into Weebly, click Edit Site, then choose Settings > SEO. Paste the Google Analytics JavaScript tracking code — not the Tracking ID — into the Header Code box. More info here.
  • Shopify: Go to your Preferences, then paste your Google Analytics JavaScript tracking code — not your Tracking ID — into the Google Analytics account box. Here are the details.

Step 4: Check the tracking code appears in your pages

Now that you’ve installed the tracking code on your site, you need to make sure it’s appearing on each page of the site. Here’s how to do that:

  1. Visit your site’s homepage.
    Open a new browser tab and go to your site’s homepage. (If you turned on the GA Google Analytics plugin’s Disable GA on the frontend for Admin-level users feature in Step 3 earlier, make sure you log out of your WordPress admin before visiting your homepage.)
  2. View the page source.
    Use your browser’s View Source feature to view the HTML source code of your homepage. For example, in Chrome, choose View > Developer > View Source.
  3. Look for the tracking code.
    Fairly near the top of the page source, you should see the Google Analytics JavaScript tracking code. It should be the same as the code that appears under Website tracking in your Google Analytics Tracking Code admin page (see Step 3: Insert the tracking code in your website):

    Google Analytics tracking code in page
    Look through your page source to find your Google Analytics tracking code.

If you don’t see the code anywhere in your page source, try clearing your browser’s cache. If that doesn’t work, check that you’ve inserted the tracking code correctly in your site’s admin.

Step 5: Check the tracking works

Your tracking code is installed on your site, but does it actually work? Follow these steps to find out:

  1. Go to the Tracking Code page in your Google Analytics admin.
    You may still have this page open from before. If not then visit analytics.google.com and click the ADMIN menu option. In the PROPERTY column, click Tracking Info, then click Tracking Code:

    Google Analytics: Tracking Code link
    In the Google Analytics admin, click the Tracking Info > Tracking Code option for your property.
  2. Send a test visit to Google Analytics.
    Make sure you’re logged out of your site admin if necessary (see Step 4: Check the tracking code appears in your pages). Then click the Send test traffic button on the Tracking Code page. This opens your site homepage in a new window, which should then register as a “visit” in Google Analytics:

    Google Analytics: Send Test Traffic button
    Click the Send test traffic button to send a test visit to Google Analytics.
  3. Check that the visit registered.
    Look closely at the “active users” text above the Send test traffic button. Within 30 seconds, you should see the figure change from 0 to 1:

    Google Analytics: Test traffic received
    Within half a minute, you should see the test visit show up on the Tracking Code page.

You’ve now set up Google Analytics tracking on your site. Nice work!

Step 6: Deal with Google Analytics spam

You know, I wish I didn’t have to write this step! Sadly though, even Google Analytics is a target for spammers these days. They send fake ‘visits’ to your site with spammy data, which then shows up in your Google Analytics reports.

If you want an easy-peasy summary of the Google Analytics spam problem, Georgi Georgiev over at Analytics-Toolkit.com has a nice infographic for you.

Dealing with Google Analytics spam is quite an advanced topic, so I’m not including it in this beginner’s guide. I don’t want to overwhelm you! But it’s definitely something you’ll want to keep on top of.

Just about the best article on this topic is Mike Sullivan’s Definitive Guide to Removing All Google Analytics Spam. I recommend you read through this a couple of times, and then go ahead and do at least the first two steps in the article:

  • 1. New Website? Use a ‘-2’ Property: Since you’ve just started using Analytics, this is a good time to do this step. It will get rid of a large chunk of your spam.
  • 2. Implement a Valid Hostname Filter for Ghost Visits: This is the best way to eliminate fake Analytics spam, so you should definitely do this step.

(If you need assistance with fighting your Google Analytics spam or setting up filters, get in touch and I’ll be happy to help!)

Get started with Google Analytics today!

Google Analytics can seem hard at first. However, if you followed this tutorial then you’ve set up an Analytics account and linked it to your website. Google Analytics is tracking your visits and you’re well on your way to becoming an Analytics ninja. You are awesome!

After a couple of days, you’ll start to see some visits appear in your Google Analytics. But how do you make sense of it all? What can Google Analytics actually tell you about your visitors, site, and business?

Never fear, dear reader. I have answered these questions — and more — in another article! Go and read How Google Analytics Can Answer These 11 Burning Questions about Your Website to get the most from your brand new Google Analytics account. Have fun! 🙂

Do you have any questions or roadblocks with setting up your Google Analytics? Feel free to ask them in the comments below!

[Image credits: Man with book by Peggy & Marco Lachmann-Anke (CC0), cropped, edited]

Filed Under: Running a Website, WordPress Tagged With: Free, Google Analytics, Marketing, Plugins, Stats, Tutorial, WordPress

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

To include a block of code in your comment, surround it with <pre> ... </pre> tags. You can include smaller code snippets inside some normal text by surrounding them with <code> ... </code> tags.

Allowed tags in comments: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre> .

Primary Sidebar

Hire Matt!

Matt Doyle headshot

Need a little help with your website? I have over 20 years of web development experience under my belt. Let’s chat!

Matt Doyle - Codeable Expert Certificate

Hire Me Today

Call Me: +61 2 8006 0622

Stay in Touch!

Subscribe to get a quick email whenever I add new articles, free goodies, or special offers. I won’t spam you.

Subscribe

Recent Posts

  • Make a Rotatable 3D Product Boxshot with Three.js
  • Speed Up Your WordPress Website: 11 Simple Steps to a Faster Site
  • Reboot!
  • Wordfence Tutorial: How to Keep Your WordPress Site Safe from Hackers
  • How to Make Awesome-Looking Images for Your Website

Footer

Contact Matt

  • Email Me
  • Call Me: +61 2 8006 0622

Follow Matt

  • E-mail
  • Facebook
  • GitHub
  • LinkedIn
  • Twitter

Copyright © 1996-2023 Elated Communications. All rights reserved.
Affiliate Disclaimer | Privacy Policy | Terms of Use | Service T&C | Credits