How to Install Google Analytics 4 (GA4)

How to Install Google Analytics 4 (GA4)

On October 2020, Google launched its new version of Google Analytics, called Google Analytics 4, or GA4 for short. From now on, GA4 is the default when you create a new property.

Google will no longer invest in the previous generation of analytics, Universal Analytics (UA).

In order to stay up to date with future GA improvements, Google recommends using the new Google Analytics 4 property alongside your existing Universal Analytics properties.

Here is the plan:

  • Create a new Google Analytics 4 property
  • Connect your existing UA property with the GA4 property
  • Install the tracking code on your website
  • Verify that the new implementation is functioning correctly by accessing the real-time report.

Let’s get down to it!

Create a new Google Analytics 4 property

If you are a new Google Analytics user, you will be prompted to create an account and agree to the end user terms of service. Once the account is created, you can proceed to create the new property.

Click Admin> Select an existing account> Click Create Property

Enter the name of your new property, choose your reporting time zone, the main currency, then click Next. Answer the question about your business and click Create, et voilà ! Your new GA4 Property is ready.

Configure your Data Stream

After creating your property, the next step is to the Set up a data stream to start collecting data windows. The data stream is the flow of data sent to GA from your app or website. A GA4 property can have up to 50 data streams and they can be any combination of app and web data streams. For the purpose of this article, we will choose Web.

Enter your website URL and the Stream name. Click the icon to select the features you want to activate.

Enhanced measurement collect events without having to change the code.

You can measure the following events by default:

  • Page view
  • Scroll
  • Outbound link click
  • Site search
  • Video Engagement
  • File Download

Once you are done, click Create stream.

Install the tracking code on your website

You can configure your website with the following methods to have data flow into the stream you have just created by:

  • adding a new on-page tag with Global Site Tags or with Google Tag Manager (GTM)
  • using an existing on-page tag with Google Analytics or GTM

New on-page tag with Global Site Tags

The Global Site Tag (gtag.js) is a javascript library from Google. Instead of having to manage multiple tags for different Google products, like Google Analytics, Google Ads, Google Marketing Platform, Campaign Manager… you can use gtag.js.

Copy and paste the gtag.js code as the first item into the <head> of every web page you want to measure.

The gtag.js looks like this:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-XXXXXXXXXX');
</script>

G-XXXXXXXXXX will be the MEASUREMENT ID of the Google Analytics 4 property we just created.

New on-page tag with GTM

Existing on-page tag with Google Analytics

If you already have gtag.js for another Google Analytics property on your page, follow these steps to turn on tagging for this stream without changing the code on your page:

  1. In a new window, open the Google Analytics property that controls your on-page tag.
  2. Go to Admin > Tracking Info > Tracking Code.
  3. Click Connected Site Tags under Global Site Tag (gtag.js).
  4. Connect your new Measurement ID.

Existing on-page tag with GTM

Verify that the new implementation is functioning correctly by accessing the real-time report.

Now, back to the Google Analytics user interface. Choose your new Google Analytics 4 property from the drop-down list> Go to Real-time reporting in the left sidebar menu

Check your implementation, you should see the events and activity on you websites as they happen.

By Delphine Ragazzi-Doumayrou

Delphine is an experienced Web Analyst and CRO Specialist with a background in Digital Marketing

Leave a comment

Your email address will not be published. Required fields are marked *