How can I set up Google Analytics

Integrate Google Analytics: create an account & implement tracking code

The web analysis tool Google Analytics gives you the opportunity to track and analyze traffic and user movements on your website and to optimize your website, content and marketing measures based on this. All you have to do to get the data is create a Google Analytics account and add the tracking code to your website. We'll show you step by step how to do it. You will also learn how to integrate Google Analytics with Google Tag Manager.

Table of Contents

Create a Google Analytics account

First of all, you have to create a Google Analytics account. You need one for thatGoogle account. If you already have one, you can simply log in to the Google Analytics homepage with your email address and password.

Registration with Google Analytics

If you don't have an account yet, click on "Create an account" and set up your Google account. You can then also use it for G-Mail, Google Ads or Data Studio.

If you already have a Google account, enter your login details and you will be taken to the Google Analytics setup page.

Registration with Google Analytics

Then simply click on "Start measurement". A form will then open that you have to fill out.

Enter account name

Next you can choose whether you want to share your data with other Google services, Google employees or general statistics. By default, three of the points are activated. Your analytics reports will work even if you don't select them. However, you should at least tick the first point if you want to use data from Analytics, for example in Google Ads. But then you have to point out in your privacy policy that you are using the Google signals feature listed below. The best thing to do is to clarify with your data protection officer whether this is possible or whether there is anything else for you to consider.

Data release with Google Analytics

Next you have to set up a property in which your data should enter. Here you have to decide whether you want to set up a Google Analytics 4 property or one for Universal Analytics. Google Analytics 4 is the new version of the web analysis tool. Compared to Universal Analytics, it offers some new features and evaluation options. Currently, however, Universal Analytics is the more common version that most website operators work with.

This article is about how to set up Universal Analytics. But it makes perfect sense to set up a Google Analytics 4 property directly. You can find out more about the advantages and disadvantages of Google Analytics 4 in the article of the same name.

To set up a Universal Analytics Property, you click on "Show advanced options". Enter a name for your property in the appropriate field above and set the time zone and currency with which you would like to work later. Then activate the Universal Analytics Property and enter the URL of your website. Then you can choose whether you just want to create a Universal Analytics Property or a Google Analytics 4 Property at the same time. There is nothing wrong with creating a property for GA4, but this article is about universal analytics, which is why I limit myself to that.

Select tracking option

In the third step, you will be asked for information about your company. Simply enter the relevant data here.

Company information

Clicking on "Create" opens the Google Analytics terms of use. Again, you choose your country. Read through the user conditions in peace (😉) and confirm them.

Accept the terms of use of Google Analytics

You also have to agree to the data processing conditions.

Data processing conditions

After you have confirmed the terms of use, you will receive theGoogle Analytics tracking code. This refers to the property that you have just created and not to the entire account. In order for data to enter your account, you now have to install it on your website.

Include Google Analytics tracking code

You can either store the tracking code directly in the source code of your website or integrate it using the Google Tag Manager.But it is important that you only include the code once on each page. If you should implement it both in the source code and via the Tag Manager, the data will enter your account twice.

Include tracking code in the source code

In order for the data on the use of your website to reach your Google Analytics account in full, you have to embed the tracking code on every subpage of your website. The tracking code is the same for all pages, you don't need to make any changes for the individual pages. It is a JavaScript file.

You can find the tracking code in your Google Analytics account under Administration> Property> Tracking information> Tracking code

You can find the tracking code in the property settings under administration

You copy the given code into the source text on every subpage of your website from which you want to receive data, so ideally all of them.

You have to store the tracking code in the source text

Ideally, you should place the tracking code in the header of your website directly after the opening element of the website. Don't worry, since the JavaScript file is loaded asynchronously, it does not affect the loading times of the website, or only to a very small extent.



<< Ideal place for the tracking code



Page content



Tip: If you use a content management system (CMS) like WordPress or Typo3, there is usually a template that specifies the structure and design of the website. This consists of several individual components, including a header that is displayed on each subpage of the website. This area is ideal for the tracking code.

Anonymize the IP address

In order to use Google Analytics in compliance with data protection regulations, you have to make sure that the IP address of your users is not transferred. To do this, add the following information to the tracking code:

gtag ('config', 'UA-xxxxxxxx-x', {'Anonymize_ip': true} );

When done, the code should look like this:

Analytics code with anonymized IP


However, you still have to replace the UA-xxxxxxxx-x entry with the tracking ID of your Analytics property. You can find them here:

You can find the tracking ID here

If you do not ensure that the IP address is anonymized, it can happen that your data is deleted by Google without warning.

Integrate tracking code with the Google Tag Manager

Alternatively, the tracking code can also be integrated via the Google Tag Manager. The advantage here is that a Google Tag Manager code only has to be stored once in the source code of the website. All changes to the tracking can then be made via the user interface of the Tag Manager. If, on the other hand, the tracking code is firmly embedded in the HTML code, it has to be adjusted manually every time you want to change something. You can find out more about the advantages of the Tag Manager in the article "Google Tag Manager: Advantages and areas of application".

A Google Tag Manager account must be set up in order to use the Tag Manager. Once you've done that, create a new container for your website here and enter the name or URL of your website as the container name. In fact, you are completely free to choose your name.

Then you can choose whether you want to use the container on a website, in an app or on AMP pages. Here you choose web. Next you will get theGoogle Tag Manager Code, which you have to copy into the source code of your website.

Add the Google Tag Manager code to your website as specified

Once you have integrated the code, you can create the Google Analytics tag for tracking.

Create a new day

You name this with Google Analytics or Universal Analytics, whichever you prefer. It is best to choose a name that also reveals to other users what is hidden behind the tag.

Name the day

When configuring the tag, you can choose between Universal Analytics and GA4. Choose Universal.

Universal Analytics is recommended as the tag type

For tracking type you select "Pageview".

Configure day

Then check the box next to "Activate settings for overwriting this day" and enter the tracking ID from your Analytics account here:

Insert Google Analytics tracking ID

In order to comply with the German data protection guidelines, you must also use the Tag Manager to use theAnonymize IP addresses. To do this, create a “Field to be defined” under “Additional settings”. You select “anonymizeIp” as the field name, and enter “true” as the value.

You also have to use anonymizeIP with the Google Tag Manager

Alternatively, you can also specify the tracking ID and anonymizeIp via a variable. Then you can no longer make any analytics adjustments in the day itself.

Next you choose the trigger. This indicates the conditions under which the tag is played. Take "All Pages" here.

As a trigger you choose "All Pages"

Then you save the day.

The tag for the analytics code is now created. However, it is not yet shown on the website. To do this, you have to publish the container first. To do this, go to "SEND" in the menu at the top right. Here you can now create and publish the first version of your Tag Manager container. Give the version a name and write a description of what exactly you have created. This will help you to understand your work steps later.

Publish Google Tag Manager Container

Then you click on "Publish" and the container goes live.

Is the data coming in correctly?

After you have integrated the tracking code - whether directly in the source code of the website or via the Google Tag Manager - you can check in the Google Analytics account whether the data is entering correctly. To do this, go to a page on your website. In the Analytics account under Administration -> Property -> Tracking information -> Tracking code, you should now see that the tracking code is active.

You can see the tracking status under administration

You can track which data is actually being recorded on your website in the reports under "Real time".

In the real-time report, you can see which activities are currently being measured on your website


In addition to the anonymization of the IP addresses, German data protection stipulates further conditions so that the data can be recorded by Google Analytics.

Query cookie consent

By default, the data that you collect with Google Analytics is saved via cookies. In order to comply with data protection in Germany and the EU, you have to inform the user about this before you start recording and obtain his or her consent. This is mostly done via Cookie bannerthat are displayed when you visit the website for the first time.

For you, this means that you can integrate the tracking code into your website without much effort and start collecting the data. In order to use Google Analytics in compliance with data protection, you also have to use the Query cookie consent. Otherwise you run the risk of being warned. Cookie tools, so-called consent management platforms, are helpful here.

Adjust privacy policy

Also in the Data protection you have to inform your users that you are collecting data. To do this, create a separate page on your website with the title Data Protection or insert a corresponding text in the imprint. It is important that the data protection declaration is accessible from every subpage of your website.

Contract for order data processing

Another prerequisite for using Google Analytics in compliance with data protection regulations is the conclusion of a contract for order data processing. While you still had to complete this in writing before the GDPR came into force, you can now easily do this yourself in digital form using the analysis tool. Simply go to the administration in the account settings in the Analytics account.

The contract for order data processing can be concluded online under account settings

Here you have the opportunity to change the data sharing that you specified when you created the account. Below is the addition on data processing. As long as you have not yet given your consent, this will be displayed accordingly.

Here the contract has not yet been concluded

View the addition and agree to it.

Addition to data processing

Then click on Save. Only then is the change made. The date of approval is recorded and will appear here from now on.

The date will be recorded upon completion

Then click on the link "Manage details of the addition on data processing". Here you enter your company name and the contact person who is responsible for your data processing. This can be, for example, the managing director or a separate data protection officer. The person must be available for contractually required communications and ensure compliance with the GDPR.

You can find more about data protection and Google Analytics in the blog article "Use Google Analytics in accordance with GDPR data protection". At this point I would like to point out that, as a digital marketing agency, lunapark cannot or may not provide qualified legal advice.


After you have deposited the tracking code on your website, the first data will enter your Google Analytics account. However, these are primarily only unfiltered page views. To get reliable data, you have to

Mareike Doll

Mareike heads the SEO team at lunapark. She originally comes from the humanities and studied German and Italian philology. She started out in online marketing as an online editor, and is now at home in the world of search engines. At lunapark, in addition to the SEO team, she is also responsible for editing the Fimern blog and is passionate about writing specialist articles. She also gives workshops and has also been a guest at one or the other SEO conference as a speaker.

Set up the Google Tag Manager account correctly

by Michaela Margner | Mar 18, 2021

With the Google Tag Manager, Google has launched a free tag management solution that makes it easier to manage tracking and conversion pixels on websites, in apps and on AMP pages. For efficient day management, a good ...

The end of Google cookies, welcome first party tracking!

by Markus Vollmert | Mar 15, 2021

At the beginning of March 2021, Google announced the end of personalized advertising as we knew it before. From 2022 onwards, the Chrome browser will no longer support third-party cookies and Google will not enter any alternative technology into the race to ...


  1. Adrian on May 18, 2021 at 9:52 am
  2. Nick Freund on September 7, 2020 at 3:28 pm
  3. Tobias on January 22nd, 2020 at 3:23 pm
  4. Sladjan Lazic on March 14, 2019 at 11:56 am
  5. Mareike Doll on February 27, 2019 at 1:45 pm
  6. christine on February 8, 2019 at 12:05 pm
  7. Silvia on June 29, 2018 at 11:57 am
  8. Stefan on August 2nd, 2017 at 5:31 pm
  9. Tom on July 12, 2017 at 10:06 am