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 receive 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.

Create a Google Analytics account

First of all, you have to create a Google Analytics account. For this you need a  Google account.  If you already have one, you can easily 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 also use it for G-Mail, Google Ads or Data Studio  .

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

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

Next you can choose whether you want to share your data with other Google services, Google employees or general statistics. All points are activated by default. 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.

On the next page you can choose whether you want to create the account for a website or a Google app. In the beta, you currently have the option of selecting cross-app and cross-web user analyzes. In addition to Analytics, you also need Firebase to track apps. But this article is mostly about website tracking, so I’ll choose option 1 here.

Next, you enter data on the website for which you want to set up Google Analytics. Enter the name of your website and the URL of the domain. Then you select an industry that suits your website, your country and the correct time zone.

Clicking on “Create” opens the Google Analytics Terms of Use. Again, you choose your country. Read through the user conditions calmly (😉) and confirm them.

Accept the terms of use of Google Analytics

You also have to agree to the data processing conditions.

After you have confirmed the terms of use, you will receive the  Google Analytics tracking code . This relates 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 add 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.

Embed 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 code

Ideally, you should place the tracking code in the header of your website directly after the opening <head> elements 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.

<html><head><< Ideal place for the tracking code</head><body>Page content</body></html>

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 every 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 must 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} );

The code should then 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 text of the website. All changes to the tracking can then be made via the Tag Manager user interface. If, on the other hand, the tracking code is firmly embedded in the HTML code, it has to be adjusted manually on each page 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 and enter the name or URL of your website as the container name. In fact, you are completely free to choose your name.

Name the day

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 receive the  Google 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 classic Analytics as the tag type.

Universal Analytics is recommended as the tag type

Better take Universal Analytics. Classic analytics is outdated. When we set up tracking for a website, we only use Universal Analytics. You don’t need to pay attention to App + Web at this point.

For tracking type you select “Pageview”.

Configure day

Then check the box next to “Activate settings to overwrite 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 also have to anonymize the IP addresses via the Tag Manager  . 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 for 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 save the day.

The tag for the analytics code is now created. But 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 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 see 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

Data protection declaration and opt-out

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

Adjust privacy policy

You have to inform your users that you are collecting their data. Create a separate page on your website with the title Data Protection or insert a corresponding text in the legal notice. It is important that the data protection declaration is accessible from every subpage of your website.

In addition, you have to enable your users to prevent the collection of data, i.e. to switch off tracking. This is known as an opt-out. Here  you can read how to add a corresponding script to your website.

In the meantime, however, it has actually become more of a standard to ask the user when visiting the website for the first time whether their data may be recorded. He can then actively consent to whether his data may be recorded and processed. You can solve this with a cookie consent tool.

Contract for order data processing

Another requirement for using Google Analytics in compliance with data protection regulations is the conclusion of a contract for order data processing. During her this before the entry into force of DSGVO  have had to conclude or in writing, you can now easily it in digital form via the analysis tool to make yourself. Just 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 on the addition to 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 regulations “. At this point I would like to point out that, as a digital marketing agency, lunapark cannot or may not provide qualified legal advice.

Conclusion

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

  • Then structure and set up your account accordingly , for example with
  • Spam filtering ,
  • IP filters  or the
  • Linking to other Google services such as the Google Search Console  or a
  • Link to your Google AdWords account .

Leave a Reply