How to Setup Google Analytics 4 on Your Website

Google Analytics 4 (GA4) is the next generation of analytics that collects event-based data from both websites and apps. The data is used to better understand the customer journey. It can track user's behavior that led to purchases and use that data to make informed decisions about how to reach new and existing customers. In this blog post we would go over how to set up GA4 on your website.

Jordan Wu profile picture

Jordan Wu

5 min·Posted 

Body of Water during Golden Hour Image.
Body of Water during Golden Hour Image.
Table of Contents

Understanding Google Analytics Hierarchy

Google Analytics is organized in the following hierarchy:

  • Organization (optional)
    • Analytics account
      • Analytics property

Organization is the topmost and optional level of a Google Analytics hierarchy. This allows products and users to be collected together in organizations and each organization may have multiple Analytics accounts.

An Account is required to access your Analytics properties. You can have one or more Analytics accounts (up to a maximum of 100). Each account can contain up to 2,000 properties. For best practice you should set up one account per company and one property per business unit.

A Property represents a grouping of data from a website and/or app in Google Analytics. Within a property, you can view reports and manage data collection. One property is called Google Analytics 4 and is the property you are going to be setting up for your account.

Google Analytics 4 property collect data through Data streams. A flow of data from your website or app to Google Analytics. There are 3 types of data stream: Web, iOS, and Android. It's recommended to have one type of data stream per property. For example, 1 web data stream per property.

Create an Analytics Account

  1. Go to https://analytics.google.com.
  2. In Admin, click Create, then select Account.
  3. Provide an account name. Configure the data-sharing settings to control which data you share with Google.
  4. Click Next to add the first property to the account.
Create an analytics account
Create an analytics account

Create a New Google Analytics 4 Property

  1. Enter a name for the property (e.g. "My Business, Inc website") and select the reporting time zone and currency. If a visitor comes to your website on a Tuesday in their time zone, but it's Monday in your time zone, the visit is recorded as having occurred on Monday.
  2. Click Next. Select your industry category and business size.
  3. Click Next. Select how you intend to use Google Analytics.
  4. Click Create and (if you are setting up a new account) accept the Analytics Terms of Service and the Data Processing Amendment.
  5. Continue to Add a data stream to start collecting data.

Add a Data Stream

  1. Click Web as your platform.
  2. Enter the URL of your primary website, e.g., "example.com", and a Stream name, e.g. "Example, Inc. (web stream)".
  3. Enhanced measurement automatically collects page views and other events. So, you recommend that you enable enhanced measurement.
  4. Click Create stream.
  5. click View tag instructions.
Add Google tag ID to a website builder or CMS-hosted website
Add Google tag ID to a website builder or CMS-hosted website
  1. Many CMSs have native integrations with Google Analytics 4. Check if your CMS lets you enter your Google tag ID. Otherwise for all other websites pick install manually.
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GOOGLE_TAG_ID"></script>
<script>
  window.dataLayer = window.dataLayer || []
  function gtag() {
    dataLayer.push(arguments)
  }
  gtag('js', new Date())

  gtag('config', 'GOOGLE_TAG_ID')
</script>

When installing manually be sure to copy and paste your Google tag immediately after the head HTML element on each page of your website. Data collection may take up to 30 minutes to begin. You can then use the Realtime report to verify that you're receiving data.

Defining Digital Analytics

In marketing, you have the concept of a purchase funnel. There are different stages within the funnel that describe customer interactions.

Purchase funnel
Purchase funnel

Acquisition involves building awareness and acquiring user interest. Behavior is when users engage with your business. Conversion is when a user becomes a customer and transacts with your business. The data you are sending to your GA4 property is used to create pre-made reports. You can check them out at Google Analytics reports. That's everything you would need to setup your website with GA4 and start generating pre-made reports!

About the Author

Jordan Wu profile picture
Jordan is a full stack engineer with years of experience working at startups. He enjoys learning about software development and building something people want. What makes him happy is music. He is passionate about finding music and is an aspiring DJ. He wants to create his own music and in the process of finding is own sound.
Email icon image
Stay up to date

Get notified when I publish something new, and unsubscribe at any time.