Set up Google Analytics 4: step by step guide



Introduction to Google Analytics 4: What's changed and why you should make the switch
Why should you switch to Google Analytics 4 (GA4) and what has actually changed compared to the previous version, Universal Analytics?
Google Analytics is an indispensable tool in online marketing because it allows you to evaluate the behavior of your users on your website. Data is at the heart of every successful strategy, and with Google Analytics, you have the ability to collect and analyze that data.
The latest version, Google Analytics 4, brings some significant changes and improvements that make it even more effective and powerful. But what are these changes and why should they motivate you to make the change?
One of the most important new features in Google Analytics 4 is the way data is collected and processed. While the old version, Universal Analytics, collects session data, GA4 focuses on collecting event data. This change allows you to gain a deeper understanding of your users' behavior and perform more detailed analyses.
Google Analytics 4 also offers an integrated option to track both a website and an app in a single Google Analytics 4 property. This was not possible in the Universal Analytics version and now opens up completely new options in evaluation and tracking. In addition, GA4 is better tailored to data protection requirements and anonymizes users' IP addresses by default.
Switching to Google Analytics 4 should therefore be in your interest to take your online marketing to the next level. In the next steps of this post, we'll show you how to set up your Google Analytics account and create your first analytics property. It's a bit different than Universal Analytics, but don't worry, we'll go through every step together.
Step-by-step guide to setting up Google Analytics 4 Property
1. Get to know the new data model
GA4 uses an event-based data model that differs from previous versions. Instead of counting sessions and page views, GA4 measures interactions or “events.” Take some time to familiarise yourself with this model before continuing.
2. Define your use cases and create a tracking plan
Decide which events and data you want to track. Create a tracking plan that documents what data you want to collect and how it relates to your business goals.
3. Review your individual information
Visit the website of Google Analytics and click “Start for free.” Sign in with your Google account, or create a new account if you don't already have one.
4. Select a new Google Analytics feature or upgrade to Google Analytics 4
After you sign in, you'll be redirected to the Google Analytics administration page. Here you can create a new GA4 property or, if you already use Google Analytics, upgrade to GA4.


5. Set up your data stream
Once your property is created, you'll need to create a data stream. This is the mechanism by which data is sent to your ga4 property. Select the appropriate type for your website (web, iOS, or Android) and enter the URL of your website and a name for the data stream. You can also do this step

After you've entered your website URL and named the data stream, a window opens. If you want to set up analytics on your website, then you'll need to embed the displayed code on your website. Read more about this in the next section on “Integrating the Google Analytics 4 code on your website.
6. Import your data
After the data stream is created, GA4 starts collecting data. It may take a few hours for the first data to appear in your account.
7. Adapt data storage to your needs
You can adjust data storage under “Property Settings” in the left navigation bar. For example, you can set the duration for which user data is kept.
Integrate the Google Analytics 4 code on your website
Integrating the Google Analytics 4 code into your website is an important step in collecting and analyzing user data. Here is how you can do that:
Step 1: Copy measurement ID
Log into your Google Analytics 4 account and navigate to the desired property. Click on “Data Streams” in the admin area. There you'll find the measurement ID that you need for your website. Copy that ID
Step 2: Add the GA4 code to your website
The next step depends on how your website is set up. You'll need to add the GA4 code to the head of every page on your site that you want to track.
If you're using a website builder like WordPress or Wix, there's likely a special area in your settings where you can add tracking codes.
If you have a custom website, you might need to manually paste the code into your site's HTML files or ask your web developer to do it for you.
The GA4 code looks something like this:
Copy code
@import url ('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;800&display=swap'); #code -container2 {display: flex; flex-direction: column; align-items: stretch; padding: 10px; margin-bottom: 10px; font-family: monospace; background-color: #212121; border-radius: 5px; width: 100%;} #code2 {margin-bottom: 10px; white-space: pre-wrap; user-select: text; /* activate text selection */} #copy -button2 {padding: 10px; border: 2px solid #08F3D3; border-radius: 10px; color: #08F3D3; background-color: black; text-align: center; text-decoration: none; display : inline-block; font-size: 16px; cursor: pointer; transition-duration: 0.4s; font-family: 'manrope', sans-serif;} #copy -button2:hover, #copy -button2:active {background-color: #08F3D3; color: black;} /* media query for mobile devices */ @media (max-width: 767px) {#code -container2 {width: 300px; /* Fixed width for mobile devices */ margin: 0 auto; /* Centering the code window */}}
Replace MEASUREMENT_ID with the measurement ID that you copied earlier.
Step 3: Verify the installation
After you've inserted the code, it's important to check that the tracking is working correctly. You can use the real-time reports in Google Analytics 4 to see if your site is sending data.
Note that there is a more efficient way to implement the GA4 code on your website, which is using Google Tag Manager. This tool can simplify the code integration process and give you advanced tracking options. You can find out more about this in the next section.
Changes in event tracking with Google Analytics 4
Google Analytics 4 (GA4) has significantly changed event tracking compared to Universal Analytics (UA).
By default, GA4 automatically captures several events, including clicks, file downloads, form launches and submissions, page views, scrolling, session starts, user engagements, and certain video interactions. GA4 also automatically collects some parameters, such as the location of the page, the referrer, the page title, the screen resolution and the language. However, if you want more comprehensive recording, custom event tracking can be helpful.
When you perform an action on a website or in an app, GA4 sends requests with detailed information about your activity, known as events. After GA4 receives these requests, it processes the submitted data and organizes it to generate meaningful reports and insights.
In GA4, you can create custom events by using other events that meet specific criteria. You can achieve this via the “Events” option in GA4 and the “Create Event” button. For example, you could create a custom event “newsletter_sign_up” on the “page_view” event if the “page_location” parameter includes “newsletter confirmation” in the URL.
Compared to UA, which provides four parameters for events to track, GA4 offers more flexibility because you can define as many event parameters as you want. This allows for highly customized event tracking with lots of data, but is no longer as easy to use as UA.
Setting up custom event tracking in GA4 requires several steps. You'll first need to add custom dimensions, which can be done in two ways: gtag and GTM-based.
To add custom dimensions in GA4, navigate to Admin > Property > Custom Definitions. Here, you can create an event-related custom dimension by entering the name of the dimension and the event parameter. For example, if you want to track clicks on your main navigation menu, you could set the event category to “Menu Clicks,” the event action to the anchor link, and the event label to the anchor text. This could be used to change the anchor text of menu items and track which attract more clicks to optimize your navigation menu for better user engagement and conversion rates.
Implementing this custom event tracking requires basic JavaScript skills. An example of how to create a custom event called menu_clicks when a user clicks on a menu item is in the following JavaScript code:
document.addEventListener ('domContentLoaded', function () {var menu_anchors = document.querySelectorAll ('.menu-items a');//Click event listener to each anchor elementMenu_anchors.forEach ((anchor) => {anchor.addEventListener ('click', (event) => {gtag ('event', 'menu_clicks', {event_category ': 'Menu Clicks',' event_action ': anchor.href,' event_label ': anchor.textContent});});});}); copy code
@import url ('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;800&display=swap'); #code -container {display: flex; flex-direction: column; align-items: stretch; padding: 10px; margin-bottom: 10px; font-family: monospace; background-color: #212121; border-radius: 5px; width: 100%;} #code {margin-bottom: 10px; white-space: pre-wrap;} #copy -button {padding: 10px; border: 2px solid #08F3D3; border-radius: 10px; color: #08F3D3; background-color: black; text-align: center; text-decoration: none; display: inline block; font-size: 16px; cursor: pointer; transition-duration: 0.4s; font-family: 'Manrope', sans-serif;} #copy -button:hover, #copy -button:active {background-color: #08F3D3; color: black;} /* Media query for mobile devices */ @media (max-width: 767px) {#code -container {width: 300px; /* Fixed width for mobile devices */ margin: 0 auto; /* Centering the mobile device Code window */}}
This analytics code can be copied and pasted into your CMS code editor. The event name “menu_clicks” can be chosen as you like and three parameters are provided, which you enter. This is an approach if you don't have Google Tag Manager and prefer a GTAG implementation.
Integration of Google Analytics 4 with Google Tag Manager
Integrating Google Analytics 4 (GA4) via Google Tag Manager is an efficient way to manage tracking on your website. Here's a simple guide:
Step 1: Login and access Google Tag Manager
Log into your Google Tag Manager account. If you don't have an account yet, create one and add a new container for your site.
Step 2: Create a new tag
In your account, click “Tags” in the left sidebar, then click “New.” Here you will create a new tag for GA4.
Step 3: Configure the tag
Give your tag a name, e.g. “GA4 Configuration Tag”. Select “GA4 Configuration” as the tag type. In the “Measurement ID” field, enter the GA4 measurement ID that you received when setting up GA4.
Step 4: Select triggers
You'll need to decide when you want this tag to be triggered. For the GA4 configuration tag, you should select the “All Pages” trigger, which triggers the tag on every page on your website.
Step 5: Save tag
Click Save to save your day.
Step 6: Publish changes
For your changes to take effect, you'll need to click “Submit” and then “Publish” to set the tag live on your site.
Step 7: Test your setup
Use the “preview” mode in Google Tag Manager to ensure that your GA4 tag is triggered correctly. You should also check the real-time reports in GA4 to see if the data is being collected correctly.
Note that this is just the basic setup for GA4 via Google Tag Manager. Depending on your specific tracking needs, you may need to create additional tags for various GA4 events.
Here is a video for you in which the setup is very well explained:
Overview of alternatives to Google Analytics 4
When it comes to tracking and analyzing your site's data, there are other alternatives besides Google Analytics 4. It's important to remember that every analytics solution has its own strengths and weaknesses, and that the choice depends heavily on your individual needs.
One of the most popular alternatives to GA4 is Matomo. This analytics tool is ideal for beginners and provides a simple and easy way to analyze website data. In contrast to GA4, which requires a website tag for tracking, Matomo works with its own tracking code. It also offers a self-hosted option that gives you more control over your data and minimizes privacy issues.
Another tool you might want to consider is Clicky. It is similar to GA4 in many ways as it also uses a website tag to collect data. Clicky is particularly known for its real-time analytics features, which allow you to monitor activity on your website in real time.
Yandex Metrica is another alternative to GA4. It's a comprehensive analytics tool that provides a wealth of information about user behavior on your site. It also includes a built-in heatmap feature that shows where people are clicking on your site.
For advanced e-commerce tracking needs, KISSmetrics could be a good choice. KISSmetrics provides detailed insights into the customer journey and can help understand the ROI of various marketing channels.
It is important to note that despite the imminent shutdown of Universal Analytics Property, many of the concepts and features used in GA4 are based on Google's experience with Universal Analytics Property.
Choosing the right analytics tool ultimately depends on your specific needs and goals. The alternatives mentioned can be a good starting point to find the best solution for your website.
Summary and thoughts on setting up Google Analytics 4
The introduction of Google Analytics 4 (GA4) brings significant improvements over the previous version, Universal Analytics. This includes a deeper understanding of user behavior through event data, integrated tracking of websites and apps in a single property, and improved data protection compliance.
In order to make optimal use of GA4, it is important to become familiar with the new data-based model and create a detailed tracking plan. In addition, GA4 offers advanced options for event tracking, which, however, is more complex and requires JavaScript knowledge.
Google Analytics 4 Frequently Asked Questions
How do I set up Google Analytics?
You create an account on the Google Analytics website, add your website information, and install the tracking code on your website.
Is Google Analytics 4 free?
Yes, Google Analytics 4 is free. However, there is a paid version called Google Analytics 360 for larger companies.
What is Google Analytics 4?
Google Analytics 4 (GA4) is the latest version of Google's web analytics tool, which provides detailed information about website visitors.
What's changing with Google Analytics 4?
GA4 focuses more on event-based tracking, integrates app and web data, offers improved data protection options, and implements a new, future-proof model for data management.