What does Google Analytics code look like

Include Google Analytics tracking code

As soon as you have registered with Google Analytics, a tracking code is available 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 has been laid.

Call up tracking code

A Google Analytics property generally corresponds to a website. In order 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 changes for the individual pages. 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 administrationPropertyTracking informationTracking code:

Access your tracking code in your Analytics account

Integrate tracking code directly into the source code

If you want to integrate the Google Analytics tracking code directly, 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 the header of your website directly after the opening elements of the website. If you use a content management system such as WordPress or Typo3, there are usually extensions that simplify the integration of the Google Analytics tracking code. 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?hl=de

Integration of the tracking code with the Google Tag Manager

The Google Tag Manager allows 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 source code of the website. 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:

Set up tracking with Google Tag Manager

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 with which you can record page views and send them to Google Analytics. To do this, choose the Workspace of your Tag Manager and then click on Add a new tag:

Set up universal analytics tag

On the following page you first select the tag type Universal Analytics out:

Select the tag type

Then some basic settings have to be made for the day:

Set up the day

  • The tag needs a name under which you can later call it up in Tag Manager
  • Enter the tracking ID from your Google Analytics property
  • The tracking type is pageview
  • Select “All Pages” as the trigger. This means that this tag is triggered every time a page is accessed and data is transmitted to Google Analytics
  • Now just save and the tag is already set up

In the last step, the container, in which there is now a new tag, has to be published. To do this, click on the button in the header of the Tag Manager Send.

Publish Google Tag Manager container

When integrating the Google Analytics tracking code via the Tag Manager, the correct functioning of the Universal Analytics Tag should be checked with the Google Tag Assistant.

Anonymize the IP address

In order to be able to use Google Analytics GDPR-compliant, you must make absolutely sure that the IP address of your users 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 go directly to the tracking code ga ('send', 'pageview'); still 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 configuration of the tag on More settings and then on Fields to be defined. Add the anonymizeIP field and the value true add:

IP anonymization in Google Tag Manager

Finally, all you have to do is save the changes and publish the new day. IP anonymization is now activated.

Privacy policy & cookie notice

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.