4 Ways to Install Google Analytics 4 on Your Website

Google Analytics BCS 6 years ago (2020-10-10) 6111 Views 2 Comments
文章目录[隐藏]

Update time: March 16, 2026

This article explains how to install Google Analytics 4 (GA4) and introduces four common implementation methods.

 

Method 1: Install GA4 Using gtag.js

This method involves deploying the gtag tracking code directly in your website’s template without using Google Tag Manager (GTM).

First, copy the GA4 tracking code from your property.

4 Ways to Install Google Analytics 4 on Your Website

Then log in to your server, locate the <head> section of your website template, and paste the code there.

4 Ways to Install Google Analytics 4 on Your Website

If you don’t have server access, simply send the code to your developer and ask them to deploy it on the site.

Read More:Installing Google Analytics 4 with gtag

Method 2: Install GA4 with Google Tag Manager (Most Recommended)

I highly recommend using Google Tag Manager to deploy GA4.

From the previous step, we know the Measurement ID is G-4X87W9BLM3.

In GTM, click「Variable」——「New」——「Choose a variable type to begin setup…」——「Constant」, name it “Measurement ID”, and then make the following settings:4 Ways to Install Google Analytics 4 on Your Website

 

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:

4 Ways to Install Google Analytics 4 on Your Website

 

 

Read More:Deploy Google Analytics 4 with Google Tag Manager(2025)

 

Method 3: Connected Site Tags

This method allows one GA4 property to forward data to another GA4 property.

To use this approach, the source GA4 property must be implemented using gtag.js.

You can configure this setting in「Manage connected site tags」——「Web stream details」:

4 Ways to Install Google Analytics 4 on Your Website

 

 

 

 

Method 4: Send Data to Multiple GA4 Properties

If you want to send data to multiple GA4 properties simultaneously, you can use the group parameter in gtag.js.

This approach currently only works with gtag implementations.

For example, when deploying GA4 normally, the configuration looks like this:

<span style="font-size: 12pt;"><a href="https://www.bbccss.com/tag/gtag" title="Read more Articles about gtag" target="_blank">gtag</a>('config', 'G-HZ4RDGTX66');
</span>

By default, this uses the default group:

<span style="font-size: 12pt;"><a href="https://www.bbccss.com/tag/gtag" title="Read more Articles about gtag" target="_blank">gtag</a>('config', 'G-HZ4RDGTX66', { 'groups': 'default' });
</span>

Both configurations have the same effect.

To send data to multiple GA4 properties, you can configure different groups:

<span style="font-size: 12pt;"><a href="https://www.bbccss.com/tag/gtag" title="Read more Articles about gtag" target="_blank">gtag</a>('config', 'GA_MEASUREMENT_ID-1', { 'groups': 'group1' });
<a href="https://www.bbccss.com/tag/gtag" title="Read more Articles about gtag" target="_blank">gtag</a>('config', 'GA_MEASUREMENT_ID-2', { 'groups': 'group2' });
</span>

If you want to send an event to GA_MEASUREMENT_ID-1, the event code would look like this:

<span style="font-size: 12pt;"><a href="https://www.bbccss.com/tag/gtag" title="Read more Articles about gtag" target="_blank">gtag</a>('event', 'generate_lead', { 'send_to': 'group1' });
</span>

In theory, this setup might also be possible using GTM, but I have not successfully tested it yet.

 

Reference

Like (5)
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
(2) friends in the comments
  1. Eagerly Waiting for your Adobe Analytics articles, plz update soon :) thanks again
    Wise2020-10-12 05:26 Reply Windows 10 | Chrome 86.0.4240.75
  2. haran-huan you are THE Best , thankyou :)
    Wise2020-10-12 05:24 Reply Windows 10 | Chrome 86.0.4240.75