How To Set Up Google Analytics: A 2021 Walkthrough

How to set up Google Analytics: A 2021 Walkthrough

Jump To:

Google Analytics is an essential tool for modern digital marketers who want to use data to make better business decisions. That is why we recommend that all of our clients set up Google Analytics on their websites. To help you do the same, we’ll walk you through exactly how to set up Google Analytics on any website, so that you can start using the information to make data-driven marketing decisions for your business.

If you aren’t familiar with Google Analytics, you can check out our Introduction to Google Analytics where we cover what Google Analytics is, what the benefits & limitations are, and some of our favorite Google Analytics tips. After you have that foundation of knowledge, the next step is to sign up and install Google Analytics on your business’s website.

Follow the steps outlined in this article to ensure you know how to set up Google Analytics correctly. 

Google Analytics Set Up Process

Google Analytics is easy to install using one simple piece of javascript code. It can be installed on many website platforms in a matter of seconds, but before we get into how to install Google Analytics on specific website platforms like WordPress, Shopify, Wix, or Squarespace, let’s first walk through the general instructions on how to set up Google Analytics no matter what web platform you are using.

There are 4 steps to set up Google Analytics properly: 

  1. Sign up for a Free Google Analytics Account
  2. Create your Google Analytics Property
  3. Get Your Google Analytics Tracking Codes
  4. Install Google Analytics On Your Website

If you are using a website platform builder like Shopify, Wix, or Squarespace, we’ve included specific instructions in step 4, but we encourage you to read the full article so that you don’t miss our Pro Tips.

Google Analytics Sign up

To sign up for Google Analytics, you must first have a Gmail or a Google-associated email address1

Once you have that, you can proceed to google.com/analytics and choose “Start for free” and create or sign-in to your Google Account

After you’ve signed in to Google Analytics, you will be taken to a welcome screen where you can click the “Start measuring” button to get started. 

Next, you will be taken to the actual Google Analytics setup. Google Analytics is organized by Account -> Property -> View so, therefore, we must create our Google Analytics Account first.

We recommend using your Business name as your Google Analytics Account Name and then choosing your preferred data sharing settings. See the options in  the screenshot below. Once you have done so, click Next.

These are our recommended selections, but feel free to choose whatever you would prefer best.

Create A Google Analytics Property

Here is where it gets a little tricky.

Before we go any further though, it is worth noting that there are actually two Google Analytics property types in use as of this blog article. That is because, on October 14, 2020, Google announced the next generation of Google Analytics2, simply called Google Analytics 4 (GA4).

The other Google Analytics property type is called Universal Analytics (UA) which is still the most widely used and supported version of Google Analytics. The complexity occurs because the Google Analytics setup process currently directs you to set up Google Analytics 4 by default, so setting up Universal Analytics takes a few more steps. 

Pro Tip: We actually recommended that you run BOTH Google Analytics Property types in parallel. Because Google Analytics 4 is a new product and all features haven’t been released, even Google recommends3 running Google Analytics 4 alongside Universal Analytics. The rest of this article will be focused on setting up both4 types of Google Analytics Properties.

Getting back to our setup process, the next screen will present the (GA4) Property Settings. Give your Google Analytics 4 property a name, such as “GA4 – yourdomain.com”, and ensure the time zone and currency are correct. 

Before clicking next, choose “Show advanced options” so you can set up a Universal Analytics property at the same time.

After clicking “Show advanced options,” turn on the switch on the right hand side, then enter your website url, and ensure the “Create both a Google Analytics 4 and a Universal Analytics property” and the checkbox below are selected. Click Next.

You will then be asked to fill out 3 optional questions (industry, size, GA use cases) about your business. Then, click the blue Create button, and accept the Google Analytics Terms of Service5 and the GDPR processing terms (if applicable). 

Congratulations! Both your Google Analytics 4 and Universal Analytics Properties will now be created and you’ll be redirected to the Google Analytics 4 Web stream details.

You may want to make note of your GA4 Measurement ID in the upper right to make future steps easier. It will start with “G-”. We have blurred ours for privacy & protection.

Get Your Google Analytics Tracking Codes

Now that you’ve signed up for a Google Analytics account and created the 2 Google Analytics Properties, it’s now time to get your Google Analytics tracking codes. 

Since we have two Google Analytics Properties, we will have 2 tracking codes: one for Google Analytics 4 and one for Universal Analytics.

Google Analytics 4 Tracking Code

To find your GA4 tracking code, click the admin Gear icon in the lower left corner, then click Data Streams and choose the data stream for the right app or website which will bring you to the Web stream details page from our last screenshot.

Expert Insight: In GA4, you may have multiple data streams6, such as one for your website and one for your app. This is similar to creating a unique Universal Analytics Property for each website or app but allows Google Analytics 4 to more easily combine data from multiple sources. You can have up to 50 total data streams in Google Analytics 4.

If this is your first time installing Google Analytics, ensure “Add new on-page tag” is highlighted blue under Tagging instructions, and expand the Global Site Tag (gtag.js) section. 

If you already have Google Analytics installed, you may be able to use the GA4 Setup Assistant7.

Copy your Google Analytics Global Site Tag tracking code which will look like this:

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

Please be sure to replace both instances of G-XXXXXXXXXX with your own Google Analytics 4 measurement ID or copy & paste your code in a note so you don’t lose it. You’ll need it later.

Expert Insight: The global site tag (gtag.js) is actually what’s called a container tag that can house multiple tags in one. You may also notice that it mentions Google Tag Manager in its code too because they both use the gtag.js javascript library. 

You can install this tracking code as is, however, it will only send data to your GA4 property so we need to modify it to also send data to Universal Analytics. To send data to both GA4 and Universal Analytics (UA), we will need to find our UA tracking code by switching over to our Universal Analytics Property.

Click the X at the top of the screen to close the Web stream details page. Then, click the property dropdown under the blue “+ Create Property” button.

You should see two items. Choose the one with the “UA-” in the parenthesis as that is your Universal Analytics Property.

Universal Analytics Tracking Code

To find your Universal Analytics tracking code, sometimes referred to as your UA code, click “Tracking Info” in the middle (Property) column of the Google Analytics Admin screen. After that click, Tracking code.

Pro Tip: Since your Universal Analytics Property was created at the same time as your Google Analytics 4 Property, they may have similar names. We recommend changing your property name (under Property Settings) to differentiate your UA from your GA4 Property. We have already changed ours in the above screenshot.

You will then be presented with your UA tracking ID and a similar looking gtag.js global site tag, but we only care about the last line of code before the </script>.

Copy the whole line that looks like: gtag(‘config’, ‘UA-123456789-1’); and make sure it contains your unique UA code so that your data is sent to your Universal Analytics Property.

Pro Tip: This line of code is known as your config line. We recommend copying & pasting your Universal Analytics config line in a note so you don’t accidentally lose it on the clipboard.

Add Google Analytics 4 and Universal Analytics to Global Site Tag (Gtag.js)

After you’ve copied your Universal Analytics config line, we need to add it right above your Google Analytics 4 config line in your Global Site tag. 

If you followed the Pro Tips and saved both pieces of code, you can now create the full Global Site Tag with both Google Analytics 4 and Universal Analytics in it. To do so, paste the Universal Analytics config line above the GA4 config line. Your complete code will look like this: 

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

If you used the code above, don’t forget to replace the sample UA code and the sample Measurement ID with your unique values.

Success! Tracking code complete. You’re now ready to add your code to your website. 

Install Google Analytics On Your Website

Now that you have your tracking code ready to go, it’s time to actually install Google Analytics on your website so it starts to populate data within Google Analytics. 

If you’ve been following closely, you may have noticed that the screenshots have already told you how to set up Google Analytics. In general, the standard implementation of your global site tag is to put it in the <head> of your website. Putting your global site tag in the head8 of your website helps ensure that it fires on every page of your website. Here is what that looks like on a simple HTML page.

<html>
  <head>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());
      gtag('config', 'UA-123456789-1');
      gtag('config', 'G-XXXXXXXXXX');
    </script>
    <title>Example HTML Page </title>
  </head>
  <body>
  // Visible website content
  </body>
</html>

The exact method of placing your gtag.js code into the <head> of your website is different depending on how your website is built, but once you’ve placed it there, that’s it! 

Google Analytics will begin collecting basic data. 

Pro Tip: Please note that setting up this Global Site Tag will only track pageview information and will not track any Google Analytics Events or Enhanced Ecommerce transactions. If you want to track those events you’ll need to set up events9 in Google Analytics.

Also, most of the major website platforms have their own integrations to try to make it easier to install Google Analytics so we have linked to those instructions below. 

However, it’s worth mentioning that by relying on these integrations, you are also relying on each platform’s development schedule. At the time of this writing, none of them officially support Google Analytics 4 properties yet. We expect most CMS platforms to introduce Google Analytics 4 integrations in the coming months.

Pro Tip: In order to give you greater control of when tags are placed on your site, we highly recommend installing Google Tag Manager which is a container tag that provides a web interface instead of having to edit your website code every single time you want to place a new tag.

Okay, now that we have gone through full instructions on how to install Universal Analytics and Google Analytics 4 on your website, we are almost done. There is still one more thing you have to do to make sure your Google Analytics tag was installed correctly on your website.

Verify that Google Analytics is working

The last step in installing Google Analytics on your website is to verify that data is being passed from your website to both your newly created Google Analytics Properties. To verify that your Google Analytics is installed correctly, you can:

Verify in the Source Code

To verify your Google Analytics has been installed correctly using your website’s source code10, open a Chrome browser on Windows. Navigate to your live website where you just installed your Google Analytics tag and right-click. Then select “View page source.” Use the find function (Ctrl + F) to search for: 

  • Global Site Tag
  • googletagmanager.com
  • gtag.js

Hopefully, you’ve found the right one, but if there are multiple Global Site Tags installed for some reason, just make sure you can find your Universal Analytics Tracking ID (UA-123456789-1) and your Google Analytics 4 Measurement ID (G-XXXXXXXXXX).

You should also confirm that your tracking code is located after the <head> tag and before the closing </head> tag.

Verify with Google Tag Assistant

If viewing the source code is intimidating to you, another approach to verify your Google Analytics installation is to use the free Google Tag Assistant browser extension. We highly recommend installing this extension because it allows you to quickly see all Google tags and diagnose installation issues without having to look at the code.

Verify with Real-Time Reports

Perhaps the best way to verify that your Google Analytics has been installed is to see if data is actually being passed into Google Analytics using the Real-Time reports in both Universal Analytics and Google Analytics 4.

Google Analytics 4 Real-Time Reports

To verify your installation using Real-Time reports, log in to your newly created Google Analytics account. In Google Analytics 4, click the clock icon which shows you your last 30 minutes of activity. 

This view is designed to tell you how your website is being used in real-time. To verify your installation, you’ll need to open a new tab and navigate to your website, the one you just installed your tag on. You can either stay on the main page or click through to view your pages. 

Now, go back to the tab with your Google Analytics 4 Real-Time report open. In a minute or two, you should see a user in your real-time reporting. If so, you know your installation is working correctly. If not, there is likely an error with your installation because your interaction is not showing up here.

You may also see multiple users on your site if you have other people looking at your website at the same time.

Universal Analytics Real-Time Reports

In Universal Analytics, click the clock icon then choose Overview to see the last 30 minutes of data. In a separate tab, navigate to your website, or the site you’ve just installed your Google Analytics code on. If you see 1+ users when you visit your website, your tag is firing as it should. Try visiting a different page and see what happens in your real-time report. You should see a user on the page you have navigated to, if everything is functioning properly.

Wrapping Up How To Set Up Google Analytics

Congratulations! You have now successfully set up and installed Universal Analytics AND Google Analytics 4 on your website and can reap all the benefits of this free website analytics solution.

If you have installed Google Analytics and noticed that you aren’t getting traffic to your site, you may benefit from an SEO audit to boost your organic traffic or could look into driving relevant traffic to your site with digital advertising on Google Ads or Facebook/Instagram.

Resources

  1. Create a Google Account – Google Account Help Center
  2. Meet the next generation of Google Analytics – Google Analytics Help Center
  3. The new Google Analytics will give you the essential insights you need to be ready for what’s next. – Google Blog
  4. Set up Analytics for a website (Universal Analytics) – Google Analytics Help Center
  5. Terms of Service | Google Analytics
  6. How Google Analytics is organized – Google Analytics Help Center
  7. Add a Google Analytics 4 property (to a site that already has Analytics) – Google Analytics Help Center
  8. Set up the Analytics global site tag – Google Analytics Help Center
  9. Set up event measurement – Google Analytics Help Center
  10. Check if a web page uses Analytics – Google Analytics Help Center

Share This Article

Share on facebook
Share on linkedin
Share on twitter
Share on reddit
Share on email

Leave a Reply

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