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:
- Sign up for a Free Google Analytics Account
- Create your Google Analytics Property
- Get Your Google Analytics Tracking Codes
- 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.
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:
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 .
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:
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
// Visible website content