Blog

Person in checkered shirt looking at analytics charts on paper
Setup and Add Google Analytics to a Website

Why should you use Google Analytics?

Google Analytics (GA) provides an important role in the web ecosystem by providing website owners a way to understand the types of people that are accessing their website. It’s very important to know:

  1. Number of people going to your website
  2. How long they are staying on your site
  3. Where they came from

The Google Analytics service suite will give you a lot more data to understand your user-base than just these 3 items but for today’s post we are just going to look at setting up GA in it’s simplest form.

If you still don’t understand the reason for using Google Analytics or want to have someone set it up for you then reach out to us.

What are we going to do?

We will setup Google Analytics and add it to our site using their script tag by placing it into our page template inside of the <head></head> tag at the very top. Let’s get started.

Step 1: Get a Gmail account

Feel free to skip this step if you already have a Gmail account or can register on your own.

Google login page for Google Analytics

If you don’t already use Gmail, you will need a Gmail account to use as the login for the Google Analytics service (or any of the Google suite). This is a simple signup process.

Go to http://analytics.google.com which will forward you to the Google login page or to a page where you can click “Sign In.”

At the bottom of the Sign In page, there is a button to “Create account.” You will want to click that button.

Google Analytics create account link

This will have a drop with two options, “For myself” and “To manage my business.” If you are looking to start a Google Business account (paid) then use the business option; otherwise, use the “For myself” option.

This will then take you to a simple account creation form. Just fill in the information like any other account creation form on the web.

Google account creation form

Step 2: Sign Up for Google Analytics

After you have registered or logged in to your Google account, you will come to a page for setting up your Google Analytics account. If somehow you got off the page or it didn’t redirect you then just go to https://analytics.google.com for the page.

Google Analytics starting page and steps

On this page, you will want to click the “Sign up” button on the left of the steps. You can ignore review the steps on the left but we are about to do those.

Step 3: Make Google Analytics account

We’re just going to assume that you are doing this for a website right now. It should default to the Website tab. You will want to go thru and fill in the account information, such as, Account Name, Website Name, and Website URL.

Google Analytics Account Sign Up Form

After you are done filling out the form, click the “Get Tracking ID” button on the bottom of the page. It will show a popup with the TOS agreements… I’m sure you will read these (hahaha) but afterwards, you will want to tick the boxes click “I Accept.”

Step 4: Find and copy your tracking tag

Now that you have an account, you just need to get the Google Site Tag for your account. This is located under the Google Site Tag header. There is a box with a snippet of code. You will want to select and copy all of the contents of this box to your clip board. See video below if you can’t find it.

Step 5: Add snippet to website

After copying the snippet, you will need to paste this inside of your website’s <head></head> tag at the very top. Here is a small example website to show you how it should be placed.
Code warning! Be careful to not remove any existing stuff, you can mess up your site if you remove something. Make sure to add the snippet only.

If this is how your website looks:

<html>
    <head>
        <title>Some Website Title</title>
        <meta charset="utf-8">
        .......
    </head>

    <body>
        <h1>I'm a simple example website!</h1>
    </body>
</html>

Then after adding it to the top, it should look like the following:

<html>
    <head>
        <!-- Global site tag (gtag.js) - Google Analytics -->
        <script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-1"></script>
        <script>
            window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
            gtag('js', new Date());

            gtag('config', 'UA-XXXXXXXXX-1');
        </script>

        <title>Some Website Title</title>
        <meta charset="utf-8">
        .......
    </head>

    <body>
        <h1>I'm a simple example website!</h1>
    </body>
</html>

Step 6: Check that it’s working

After adding the snippet, you can check that it’s working on your site by going to the GA dashboard and watching the “Active Users right now” section while refreshing the page in another browser window or tab. The counter should go up to 1.

Google Analytics active users count

There you are all set! Now you can view data across the toolset about your website visitors.

If you run into issues or want to do some more advanced setup — reach out to us for assistance.

Read More