Installing Google Analytics 4 with gtag.js

Google Analytics BCS 7 years ago (2019-12-18) 3540 Views 0 Comments

Update time: March 13, 2026

This guide explains how to properly set up Google Analytics 4 (GA4) using the gtag.js tracking code, from property creation to installation and verification.

Step 1:Create GA4 Property

To begin, log in to GA4 and navigate to「Admin」——「+Create」——「Property」:

Installing Google Analytics 4 with gtag.js

 

Create Property

Then configure the basic property settings:Installing Google Analytics 4 with gtag.js

  • Property name: Use your website domain (recommended for clarity)
  • Reporting time zone: Select your local or business time zone
  • Currency: Choose the currency used for reporting and e-commerce data

Click 「Next」to continue.

 

Business Details

Next, Google Analytics will ask for business details. These are used to improve reporting insights and recommendations.

  • Industry category (Required): Select the most relevant industry for your website or business
  • Business size (Required): Choose the number of employees in your organization

Installing Google Analytics 4 with gtag.jsClick 「Next」 when done.

Business objectives

In this step, GA4 asks for your business goals.

These settings help Google Analytics customize default reports and insights based on your use case (e.g., lead generation, sales, traffic acquisition).

Installing Google Analytics 4 with gtag.js

Select the options that best match your objectives, then click「Create」.

 

Data collection

In this step, you will create a Data Stream:
Installing Google Analytics 4 with gtag.js
GA4 supports three types of data streams: IOS, Android and Web, Multiple streams can send data to the same GA4 Property.

Step 2:Configure the Web Data Stream

For a website implementation, choose Web to create a web data stream.
Installing Google Analytics 4 with gtag.js
  • Website URL: Enter the homepage URL of your website.
  • Stream name: Provide a name for the website or data stream.
  • Enhanced measurement: This feature automatically tracks several common interactions (such as page views, scrolls, and outbound clicks). By default, all options are enabled. You can disable any that you do not need.

After completing the setup, click「 Create & Continue」to create Data Stream.

Understand Data Stream Details

Once the Data Stream is created, you will see its details:

Installing Google Analytics 4 with gtag.js

  • STREAM URL: Your configured website URL
  • STREAM NAME: The name you assigned
  • MEASUREMENT ID: Used for web tracking
  • STREAM ID: Internal GA4 identifier (mainly used for app configurations)

Step 3:Install gtag on Your Website

In Web stream details ,click「Installation instructions」——「Install manually」

Installing Google Analytics 4 with gtag.js

Copy the gtag code snippet provided in GA4, log in to your website server or CMS, paste the code inside the <head> section of your website template.

Installing Google Analytics 4 with gtag.js

If you do not have server access, send the code snippet to your developer and ask them to add it to the site.

 

Step 4:Test and Verify the Installation

After installation, you should verify that GA4 is receiving data correctly.

Open Developer Tools in your browser and go to the Network tab. Filter requests using v=2

Installing Google Analytics 4 with gtag.jsIf GA4 is working correctly, you should see requests sent to the GA4 collection endpoint (e.g., google-analytics.com/g/collect).

 

Like (0)
Post my comment
Cancel comment
Expression Bold Strikethrough Center Italic

Hi, you need to fill in your nickname and email!

  • Nickname (required)
  • Email (required)
  • Website