Update time: June 5, 2025
In this article I will show you how to deploy Google Analytics 4 through Google Tag Manager.
Install Google Tag Manager
Creates GTM Container
First, create a container in GTM, click「⋮」——「Create Container」:
Then see the setting interface of the Create Container:
- Container Name:Custom container name, usually fill in the domain name, here it is named http://www.bcs.com
- Target Platform:According to the actual situation, choose Web here.
Finally click 「Create」 to create a new container.
Deploy the GTM Library Code to the Website
Click to open the container you just created, click「Admin」——「Install Google Tag Manager」:
The code has two paragraphs, need to be installed on all pages of the website, usually installed on the template page, one that needs to be deployed to the header, and one that needs to be deployed to the body.
If you don’t have server permissions, you need to let the development colleagues handle it.
Test
Finally, it is time to test. Before testing, you need to publish a version in GTM to ensure that GTM can load normally. Note that if there is no published version, GTM will prompt a 404 error when loading.
In GTM, click 「Submit」——「Publish」 the upper right corner to publish.
Open the website in the browser, then open the browser developer tools, click Network, and then filter with “GTM”. You can see that GTM’s JS can be loaded normally, and the status is 200, indicating that the deployment is fine.
Read More:Install Google Tag Manager on Your Website
Create GA4 Property
In GA4, click 「Admin」——「+Create」——「Property」:
Create Property
- Property name: Generally fill in the domain name of the website.
- Reporting time zone: Fill in your time zone.
- Currency: Select the currency type.
After configuration, click 「Next」.
Business Details
- Industry category(Required): Select the industry type of the website.
- Business size (Required): Select number of employees
After configuration, click 「Next」.
Business objectives
This setting will mainly generate some built-in reports for different industries. Choose according to your needs:
After configuration, click 「Create」.
Data collection
- Website URL: Set the homepage address of the website.
- Stream name: Set the name of the website.
- Enhanced measurement: Some of the built-in tracking can be achieved only by checking, which is very convenient.default is to select all, you can remove it according to your needs.
After setting, click「 Create & Continue」to create Data Stream.
Data Stream is set up, this is the detailed information of the data stream.
- STREAM URL: The default address of the website.
- STREAM NAME: Site name.
- MEASUREMENT ID: similar to Tracking ID.
- STREAM ID: similar to Tracking ID.
MEASUREMENT ID and STREAM ID are similar to Tracking ID, but MEASUREMENT ID can only be used in the Web, and STREAM ID can only be used in APP.
GA4 is now set up. Copy the MEASUREMENT ID, which will be used in the next step.
Configure GA4 on GTM
Configure GA4(Google Tag)
From the previous step, we know that the measurement ID is G-4X87W9BLM3. Create a Constant variable to store it for later reuse.
In GTM, click「Variable」——「New」——「Choose a variable type to begin setup…」——「Constant」, name it “Measurement ID”, and then make the following settings:
In GTM, click「Tags」——「New」——「Choose a tag type to begin setup…」——「Google Analytics」——「Google Tag」, name it “GA4 Tracking Code”, and then make the following settings:
Preview and Test
Next is the preview test. Click 「Preview」 in the upper right corner.
It will open the Tag Assistant:
- Your website’s URL: Enter the domain name to be tested. Here, it is https://www.bbccss.com
- Include debug signal in the URL: Uncheck
Finally, click “Connect” and it will open the website. You will see Tag Assistant Connected in the lower right corner of the website, indicating that it has successfully entered the test state:
Return to Tag Assistant and find Window Loaded in Summary. You can see that the configured GA4 Tracking Code is triggered:
This means that the configuration is fine.
You can also verify it in GA4’s Debugview and real-time reports, where you can see the data.
Publish
If there are no problems with the test, you can publish it.
In GTM, click 「Submit」——「Publish」 the upper right corner to publish.