Integration of Google Analytics
As soon as you have registered with Google Analytics, you will have a tracking code for each property. In this article, you will find out where you can get the code and how you can integrate it on your website, either directly or with the help of Google Tag Manager. At the end of this article, the basis for further work with Google Analytics is laid.
Call up tracking code
A Google Analytics property generally corresponds to a website. For the data on the use of your website to reach your Google Analytics account in full, you have to integrate the tracking code on every subpage of your website.
The tracking code is the same for all pages, so you don’t have to make any individual pages changes. However, it is important that you only insert the code once per page. Otherwise, the data will enter your account twice. You can find the tracking code in your Google Analytics account under Administration → Property → Tracking information → Tracking code:
Integrate tracking code directly into the source code
Suppose you would like to embed the Google Analytics tracking code directly. In that case, you simply copy the complete tracking code snippet from your Google Analytics property and paste it into the code of your website. Ideally, you should place the tracking code in your website’s header area directly after the opening elements of the website.
If you use a content management system like WordPress or Typo3, there are usually extensions that simplify integrating the Google Analytics tracking code. This means that no intervention in the source code of your site is necessary.
If the tracking code is now integrated on your website, you should check whether the tracking code is working correctly. There is a very helpful extension for the Chrome browser called Google Tag Assistant: https://support.google.com/analytics/answer/1008083
Integration of the tracking code with the Google Tag Manager
The Google Tag Manager enables you to set up and maintain many different tracking codes in one central location. The advantage is that a Google Tag Manager code only has to be stored once in the website’s source code. All changes to the tracking can then be made via the Tag Manager user interface.
After you have created your Google Tag Manager account, you will receive two code snippets that you have to include on your website:
The first code snippet should be placed as high up in the area as possible. The second snippet should be used immediately after the opening tag.
After you have installed the tag container on your website, all you have to do is set up a universal analytics tag. This tag contains the Analytics tracking code, which you can use to record page views and send them to Google Analytics. To do this, select the workspace of your Tag Manager and then click on Add New Tag :
On the following page, first, select the Universal Analytics tag type:
Then some basic settings have to be made for the day
- The tag needs a name under which you can later call it up in the Tag Manager
- Enter the tracking ID from your Google Analytics property
- The tracking type is a pageview
- Select “All Pages” as the trigger. This means that this tag is triggered every time a page is viewed and data is transmitted to Google Analytics
- Now just save, and the tag is already set up
In the last step, the container has to be published in which there is now a new tag. To do this, click the Send button in the header of the Tag Manager.
When integrating the Google Analytics tracking code via the Tag Manager, the Universal Analytics Tag’s correct function should be checked with the Google Tag Assistant.
Anonymize the IP address
To be able to use Google Analytics GDPR-compliant, you must make sure that your users’ IP address is not transferred. IP anonymization means that the last octet (the last digits before the first point) of the IP address is made unrecognizable before the tracking code transmits the data to the analytics server.
The procedure is simple: If you have integrated the tracking code directly, you have to enter ga (‘send,’ ‘pageview’) in the tracking code, the line ga (‘set,’ ‘anonymizeIp,’ true); insert.
If you already use the Google Tag Managers, you have to add the Universal Analytics Tag `to it. Select the tag, click in the tag’s configuration on Additional settings, and then on Fields to be defined. Add the anonymizeIP field and the value true :
Finally, all you have to do is save the changes and publish the new day. IP anonymization is now activated.
Note that if you use Google Analytics, you have to inform your website visitors about it. Please contact a specialist lawyer to receive more information about a legally compliant data protection declaration and a correct reference to the use of Google Analytics cookies.
Done! You have created the basis for working with Google Analytics. In the next chapter, you will learn how to define and set an event value for goals.