How to Setup & Install Google Analytics on Your Website
Google Analytics has been and remains as the global leader for site statistic software. Why? To start with, it is free, and it offers a robust set of tools for you to track statistics on your site. If you want to know more about your site visitors and their demographics and behavior, want your sales pages to convert more, or want to know how one of your blog posts compares to another in views, you should be using Google Analytics. But what do you do if you don’t know how to install Google Analytics or how to use it once it is setup?
Unfortunately, many people don’t understand the details of how Google Analytics works, and what the different statistics mean. Because of this, I decided to write a blog aimed at teaching site owners with beginner and intermediate skill levels how to get started with GA. This is part one of a multipart series on using Google Analytics to track statistics for your website. In this installment, I’ll show you how to sign up for an Analytics account and how to install the tracking code on your site.
Google Analytics Setup and Installation
Signing up for Google Analytics
To get started, you’ll need to sign up for a Google Analytics account. If you already have one, great! Otherwise, you’ll need to go to the Analytics Home Page, and click “Create An Account”. The page will redirect you to a login screen. Now, if you already have a Google account for other services, like Gmail, Drive, or Reader– you can use that same email address here, if you want to. Otherwise, click the “Sign Up” button in the top right, and you’ll be brought to a page that looks like this:
Fill out the information it asks for, and then submit the form. Make sure you use a valid email address that you have access to. Once you submit your information, you’ll then see a page telling you that you need to confirm your email address that you entered. At that point, you should go to the email account you registered with, and look for an email from Google. It will have a verification link in the email that you’ll need to click to activate your Google Account.
Once you’ve clicked the verification link, you’ll be brought to a Google Analytics sign up page:
Obviously, at this point you’ll need to click Sign Up, which will then take you to the page where you’ll set up your website for tracking in Google Analytics.
In this area, there’s several things you’ll need to fill out in order to properly configure your account for your site(s). Let’s look at each of them.
1. What would you like to track?
The only options here are Website and App. For the purposes of this tutorial, which is geared towards Websites only, choose Website.
2. Website Name
This is the name you want the website to show up as in your Google Analytics account. It’s not public, and only you will see it. Use a name or nickname for the site that will immediately identify it to you when you access your panel. Although it may not be a big deal with only 1 site in your control panel, if you eventually add more sites to Google Analytics, you want to make sure you can identify them easily.
3. Website URL
Just like it indicates, put your website URL in this box. For most websites, you can leave the dropdown at the beginning of this field set to “http://”. However, if your site is one that is ALWAYS in secure mode, change this to “https://”.
Type your website URL in the box, including the precursor www. If the site you want to track is in a folder or subdomain, make sure you fill out this URL correctly (ie: shop.musemarketing.net or www.musemarketing.net/blog).
4. Industry Category
This setting does not affect how Google Analytics collects data on your site, but it will help them recommend certain settings or features based on what you choose.
5. Reporting Time Zone
Please be accurate when choosing your country and time zone. Google can track when visitors arrive from hour to hour, giving you valuable data about traffic patterns on your site. If you do not set your location and time zone correctly, this information is much less useful.
6. Account Name
Google Analytics can support multiple websites under an account name. So for example, if you wanted to track your companies various websites here, you might do something like “My Company’s Sites” for the account name. Then, you can go back and add more websites to that account. This feature is particularly useful for tracking client sites, as instead of making separate accounts for each of them, you can track them under an Account Group..
7. Data Sharing Settings
There are two boxes here, which by default are checked. The first one asks if you want to share your Google Analytics data with other Google products. I recommend leaving this checked. If you do, then later on you can integrate Analytics with other tools Google offers like AdSense and Webmaster Tools.
The second box asks if you want to share anonymized data with 3rd parties. This basically means Google can share information about how you use Analytics (but not who you or your company are) with third parties. This setting is really up to you, but I prefer to uncheck this box.
Ready for the next step? Now you have filled out this information, click the “Get Tracking ID” button. A terms-of-service page will pop up, prompting you to scroll through and read it before clicking “I Accept”. Once you’ve accepted the TOS, you’ll be redirected to your Google Analytics account.
Tracking Code Settings
Before you get all gung-ho on the next page that Google sends you to, you need to pick some more settings, as they will affect the code that you copy and paste into your site. At the top of this page, you’ll immediately see that it tells you your account number, which begins with a UA, and then has a string of numbers (redacted in the photo below). It will also tell you the current status of your tracking code. As this is a new setup, it says the current status is “Not Installed”.
Subdomains of (your website): Remember how I said it could track other subdomains on your site? If you want it to do so, tracking stuff like store.yourwebsite.com and blog.yourwebsite.com, flip this toggle to ON. Otherwise, leave it to OFF.
Multi-level top domains of (your website): Do you have your website across multiple TLDs, like www.yourwebsite.com and www.yourwebsite.info, or multiple language versions, like www.yourwebsite.fr and www.yourwebsite.com.au? If so, and you want to track these other sites, flip this toggle to ON. Otherwise, leave it to OFF.
Display Advertiser Support: This is a relatively new feature by Google. They now offer remarketing services. This means that if you spend money on this service, they will serve up targeted ads to people who have ALREADY visited your site, as they browse other websites around the web. Remarketing is a valuable advertising tool, but if you don’t plan on using it, you can leave this set to OFF. If you do want to use this service in the future, change this to ON.
Custom Campaign Tags: This is advanced support for allowing you to specify certain paid keywords to track and label them how you want to, instead of how they’re served by AdWords. For almost everyone reading this post, this can be set to OFF.
Once you have chosen the parameters in these four areas, you’ll notice that the code in the box below the toggles may have changed based on your choices. After you have chosen these parameters, you are ready to install your code.
Installing your Google Analytics Tracking Code
Now, you’re ready to get your code installed. Your tracking code will look something like this (UA-XXXXXXXX-X will be replaced with your unique account number):
Now, on to the installation. Most people when they get to this stage have 2 basic questions: Where to Install the Google Analytics Tracking Code, and How to Install the Google Analytics Tracking Code. Let’s look at each of these questions in-depth.
Where to Install It? In the past, Google used a different type of tracking code than the current asynchronous snippet you get from Google Analytics. This old code didn’t perform as well in certain areas of websites, resulting in inaccurate visitor counts, and even slowing down websites as the script loaded. For that reason, many people used to put the tracking code at the end of a webpage. You might still find tutorials out there that recommend this method, but they are out of date and inaccurate. For today’s Google Analytics code, you want to install it in the <head> section of your website, near the top of your code.
How to Install It? Long story short, you’re going to copy and paste it! Exactly how to do so is going to depend on what type of website you have. For the purposes of this tutorial, I’m going to assume you know how to open up the pages of your website with a code editor of some sort, like Dreamweaver, EditPlus 3, or Notepad ++.
What we do next will depend on what kind of site that you have. I will cover three common variations here.
HTML Websites: If you have a site built with static HTML pages, you’ll probably have a bunch of files that all end in .htm or .html. This is probably going to be the most annoying installation process of the 3 I am covering. For Analytics to track a page, the tracking code has to be present on that page. So, if you just want Google to track your home page, that’s not so bad. But if you want them to track every page in your site, then that means the tracking code will need to be copied and pasted to every page, as well. Make sure to make a backup of your site somewhere safe before you start editing files, so if you make a mistake, you can restore to the previous version.
Using one of the code editors I mentioned above, open up your home page, which could be something like index.html, home.html, or default.html. You will likely see something like this in the code:
<!DOCTYPE html> <html lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="keywords" content="your, keywords, here" /> <meta name="description" content="This is a description of my website." /> <title>Title of This Page in my Websites</title> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body> All the body content of your site....etc...
Now, you’ll want to take the tracking code Google Analytics gave you, and paste it in directly before the </head> tag in your code. Your result should look like this:
Save the file, upload it to the server, and then repeat this process with all other HTML pages in your site you want to track. That’s it!
PHP Websites: If you have a dynamic site built with PHP, your job probably just got a lot easier! Open up your home page (probably index.php) in a code editor, and near the top of your site’s code, look for a line that looks similar to
<?php include 'header.php'; ?>
If your programmer was smart, they created a header.php file, which contains all the information about stylesheets, meta tags and scripts to load in your site’s header. Instead of typing it all out for every page in your site, they then include the header.php file in the other site files. That way, if anything ever changes in the header file, it gets reflected across the entire site, instead of having to apply the changes to each page in the site one at a time. If you see something like this in your code, you are in luck. You can now just add the Google Analytics code to your header.php, and you’re good to go. Use the same process as described for the HTML site above, copying the GA tracking code into your header.php at the end of the file. This also could be done in any other file included in all pages of your site, like a footer.php or sidebar.php (if you don’t have a header.php).
If you don’t have any “included” files in your PHP code, then your programmer should be taken out and shot, because you’re going to have to repeat the process for HTML sites above– copying and pasting the Google Tracking Code to each PHP page on your site. Sorry, we know it stinks.
WordPress Websites: If you have a WordPress website, you probably have it easiest of all when it comes to Google Analytics installation. Many themes for WordPress have options in their Control Panel for you to enter your Google Analytics code. So first of all, check your Theme’s options panel and see if there is a place for you to enter your GA code, or a place to enter code that will appear in your <head> section. If there is such a place, you can just copy and paste your code to this area (some themes even allow you to just enter your UA number, and they’ll generate the code for you).
If your theme doesn’t have an option for this, then the next easiest solution is to get a plugin to do it. If you want as simple as possible, go for this Google Analytics plugin, which lets you just enter your UA number. If you want a more robust plugin with more options and features, try the Google Analyticator plugin.
Verifying you Installed Google Analytics Correctly
After you’ve put in your tracking code, you will want to make sure you did it correctly. To do this, go to your website in your browser. Once the page has loaded, right click and choose “View Source”. This will show you the live code as it is being displayed by your site. An easy way to find your code is Ctrl + F to search the source code for your UA number.
In our testing site’s source code, shown above, you can see the tracking code in there successfully (I redacted our UA number). Now, you can go back to your Google Analytics panel and check to see if they have verified your code.
When you log in, you’ll reach a screen that looks like this:
To check on your site’s tracking status, click on All Web Site Data under your website name. Then, in the top right of your screen, click the Admin button. This will bring up your admin settings for this particular website. Click on the tab that is called Tracking Info, and hopefully this is what you will see:
SUCCESS! Your tracking has been installed! At this point, it will take Google around 24-48 hours for it to start displaying your statistics in Analytics, so be patient.
What if it still says “Tracking Not Installed”? If your panel still says the code is not installed, be patient. Google may not have checked your site again since you installed the code. Give it an hour or two and check again. If at that point it still says Tracking Not Installed, you will need to go back and double check everything you did. Make sure you didn’t leave out part of the code when you copied, or accidentally put in the wrong UA number.
Next Time: How to Configure Google Analytics
That concludes this part of the tutorial on Google Analytics. I hope you enjoyed it and learned a lot. Please feel free to leave comments or questions if you have them. In the next installment of this series, I’ll take a look at configuring some basic settings for Google Analytics, like filtering out your IP address so it doesn’t appear in your statistics.