Setting up Google Analytics 4: Step-by-step instructions



Introduction to Google Analytics 4: What has changed and why you should switch
Why should you switch to Google Analytics 4 (GA4) and what has changed compared to the previous version, Universal Analytics?
Google Analytics is an indispensable tool in online marketing because it allows you to analyze user behavior on your website. Data is at the heart of any successful strategy, and Google Analytics gives you the opportunity to collect and analyze this 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 switch?
One of the most important changes in Google Analytics 4 is the way data is collected and processed. While the previous version, Universal Analytics, collected session data, GA4 focuses on collecting event data. This change allows you to gain a deeper understanding of your users' behavior and conduct more detailed analyses.
Additionally, Google Analytics 4 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 entirely new possibilities for analysis and tracking. In addition, GA4 is better aligned with data protection requirements and anonymizes user IP addresses by default.
So, switching to Google Analytics 4 should be in your best 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 little different than with Universal Analytics, but don't worry, we'll walk you through each 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 familiarize yourself with this model before proceeding.
2. Define your use cases and create a tracking plan
Consider 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. Check your individual information
Visit the Google Analytics website and click "Start Free." Sign in with your Google Account or create a new one if you don't already have one.
4. Choose a new Google Analytics property or upgrade to Google Analytics 4
After logging in, you'll be redirected to the Google Analytics admin 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 need to create a data stream. This is the mechanism through which data will be sent to your GA4 property. Select the appropriate type for your website (Web, iOS, or Android) and enter your website's URL and a name for the data stream. You can also skip this step.

After you enter your website URL and name the data stream, a window will open. If you want to set up Analytics on your website, you'll need to embed the displayed code. More on this in the next section, "Integrating Google Analytics 4 Code on Your Website."
6. Import your data
After the data stream is created, GA4 will begin 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 customize data retention under "Property Settings" in the left navigation bar. For example, you can specify the length of time user data is retained.
Integrating Google Analytics 4 code on your website
Integrating Google Analytics 4 code into your website is an important step in collecting and analyzing user data. Here's how:
Step 1: Copy measurement ID
Log in to your Google Analytics 4 account and navigate to the desired property. Click on "Data Streams" in the admin area. There you will find the measurement ID you need for your website. Copy this ID.
Step 2: Insert the GA4 code into your website
The next step depends on your website's structure. You'll need to add the GA4 code to the header of each page of your website that you want to track.
If you use a website builder like WordPress or Wix, there's probably a special section in your settings where you can add tracking codes.
If you have a custom-designed website, you may need to manually insert the code into your website'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; /* Textauswahl aktivieren */ } #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 für Mobilgeräte */ @media (max-width: 767px) { #code-container2 { width: 300px; /* Feste Breite für Mobilgeräte */ margin: 0 auto; /* Zentrierung des Code-Fensters */ } }
Replace "MEASUREMENT_ID" with the measurement ID you copied earlier.
Step 3: Check the installation
After you've inserted the code, it's important to check if tracking is working correctly. You can use the real-time reports in Google Analytics 4 to see if your website is sending data.
Note that there is a more efficient way to implement GA4 code on your website, namely using Google Tag Manager. This tool can simplify the code integration process and provide you with advanced tracking options. Learn 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).
GA4 automatically tracks several events by default, including clicks, file downloads, form launches and submissions, page views, scrolls, session starts, user engagements, and certain video interactions. GA4 also automatically tracks some parameters, such as page location, referrer, page title, screen resolution, and language. However, if you want more comprehensive tracking, 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, called events. After GA4 receives these requests, it processes and organizes the submitted data to generate meaningful reports and insights.
In GA4, you can create custom events by using other events that meet certain criteria. You can do this via the "Events" option in GA4 and the "Create Event" button. For example, you could create a custom "newsletter_sign_up" event 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, allowing you to define as many event parameters as you want. This allows for highly customized event tracking with a lot of data, but is no longer as easy to use as UA.
Setting up custom event tracking in GA4 requires several steps. You first need to add custom dimensions, which can be done in two ways: Gtag-based 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 dimension name 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 ones attract more clicks, allowing you to optimize your navigation menu for better user engagement and conversion rates.
Implementing this custom event tracking requires basic JavaScript knowledge. An example of how to create a custom event named "menu_clicks" when a user clicks a menu item is shown 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});});});});Code kopieren
@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 für Mobilgeräte */ @media (max-width: 767px) { #code-container { width: 300px; /* Feste Breite für Mobilgeräte */ margin: 0 auto; /* Zentrierung des Code-Fensters */ } }
This analytics code can be copied and pasted into your CMS code editor. The event name "menu_clicks" can be chosen arbitrarily, and three parameters are provided for you to specify. 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: Log in and access Google Tag Manager
Log in to your Google Tag Manager account. If you don't already have one, create one and add a new container for your website.
Step 2: Create a new tag
In your account, click "Tags" in the left sidebar and then "New." This is where you'll 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 you received when setting up GA4.
Step 4: Select trigger
You need to specify when this tag should be triggered. For the GA4 Configuration Tag, you should select the "All Pages" trigger, which will fire the tag on every page of your website.
Step 5: Save tag
Click "Save" to save your tag.
Step 6: Publish changes
For your changes to take effect, you must click "Submit" and then "Publish" to make the tag live on your website.
Step 7: Test your setup
Use the "Preview" mode in Google Tag Manager to ensure your GA4 tag is firing correctly. You should also check the real-time reports in GA4 to see if the data is being collected correctly.
Note that this is only the basic setup for GA4 via Google Tag Manager. Depending on your specific tracking needs, you may need to create additional tags for different GA4 events.
Here is a video for you that explains the setup very well:
Overview of alternatives to Google Analytics 4
When it comes to tracking and analyzing your website data, there are other alternatives besides Google Analytics 4. It's important to remember that each analytics solution has its own strengths and weaknesses, and 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 offers a simple and straightforward way to analyze website data. Unlike GA4, which requires a website tag for tracking, Matomo works with its own tracking code. It also offers a self-hosted option, giving you more control over your data and minimizing privacy concerns.
Another tool you might consider is Clicky. It's similar to GA4 in many ways, as it also uses a website tag for data collection. 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 website. It also includes a built-in heatmap feature that shows where users click on your website.
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 impending shutdown of Universal Analytics Property, many of the concepts and features used in GA4 are based on the experiences Google has had with Universal Analytics Property.
Choosing the right analytics tool ultimately depends on your specific needs and goals. The alternatives mentioned can provide a good starting point for finding 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. These include a deeper understanding of user behavior through event data, integrated tracking of websites and apps in a single property, and improved privacy compliance.
To get the most out of GA4, it's important to familiarize yourself with the new data-driven model and create a detailed tracking plan. GA4 also offers enhanced event tracking capabilities, but this is more complex and requires JavaScript knowledge.
Frequently asked questions about Google Analytics 4
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 changes with Google Analytics 4?
GA4 focuses more on event-based tracking, integrates app and web data, offers improved privacy options, and implements a new, future-proof data management model.