Integrate and use Google Analytics in Wordpress - how it works
Related Videos: How to Install Google Analytics for WordPress (May 2024).
Integrating and using Google Analytics is child's play if you have a WordPress website. In this article you will read step by step how to do this. By CHIP expert Florian Kolbe
The advantages of Google Analytics for your WordPress site
Google Analytics is a valuable tool to get to know and analyze the flow of visitors on your own WordPress site.
- The tool proves to be extremely helpful, especially for online marketing.
- However, you will also be able to understand the visitors of your website. You can use the data to create better content for your users.
- But how do you integrate Google Analytics into the fresh WordPress page? We will address this question extensively in this article.
Connect Wordpress with Google Analytics: The three classic ways
There are basically three ways you can include Google Analytics in Wordpress:
- Direct integration via the source code
- Integration via a plugin - probably the best option for beginners
- Integration via the Tag Manager from Google
Integrate Google Analytics: The way via the source code
Fortunately, you do not need any programming knowledge to store the necessary Google Analytics tracking code in the source code of your WordPress site. It is enough to know where you are looking and where to copy the code. Here's how to find the Google Analytics code:
- Create a Google Analytics user account and log in.
- Click on the tab labeled "Manage".
- Click "Tracking Information" in the middle column
- Here you will find the "Tracking Code" as a sub-item
- Copy the code shown
Footer or header: where you can insert the tracking code
You must now integrate the tracking code on your WordPress website. There are two ways to do this.
- On the one hand, the tracking code can be integrated into the footer. However, the code can also be included in the header of the page. This has no influence on the functioning of the website and the code.
- If the header is integrated, the code is loaded right at the start of the page call. Under certain circumstances, this can have a negative impact on the loading times of the website.
- If the Google Analytics code is integrated in the footer, it is only loaded when the entire page is loaded.
How to embed the tracking code in Wordpress
- Log in to WordPress as an administrator.
- Select the "Design" item in the left navigation column.
- Now select the sub-item "Editor".
- Now select the file "Header.php" or "Footer.php" in the right column. Depending on how you want to embed the code.
- Copy the entire code snippet before the last two HTML tags in the file you selected (usually the code has to be inserted on the third to last line).
- Save - Google Analytics is now integrated in WordPress.
Integrate Google Analytics via a plugin
The easiest method for beginners is to use a plugin. However, you are in the hands of the respective plugin provider, which is why the variant via the code is generally considered more reliable.
- A proven and free plugin is for example "Google Analytics for Wordpress".
- It is important that you always select "anonymize IP" or "anonymize IP's" in the setting options of the plugin. Incidentally, this applies to all plugins that you may install. Otherwise you come into conflict with the German data protection law.
- Integration takes place with just one click - you will find the associated button next to the respective plugin.
- It is important that you are logged in to WordPress as an administrator. Otherwise you can only download the plugin.
Alternative Google Tag Manager
Google Tag Manager is basically a container system. It enables the management and integration of various tracking codes and tags.
- The advantage of such a tag manager is that only this has to be integrated into the source code.
- All other tracking codes are then managed via the Tag Manager. This sounds a lot more complicated than it actually is.
- It is important that you create a user account with Google Tag Manager with the same email address as with Google Analytics.
- You have to give your new account a name - choose your WordPress URL here.
How to install Google Tag Manager
- Log in to Tag Manager with your Google Account.
- In the work area, click your container ID.
- After clicking you will receive the code snippet to install the Google Tag Manager. Copy this code and save it in Notepad if necessary.
- In the administrator area of Wordpress, open the editor of the theme and copy the saved code of the tag into the file "header.php". Here the code must be inserted directly after the tag
- If there is no "header.php" file in the theme, there should be a "functions.php" file. Here the code is simply inserted at the end.
- If you read "Past Google Code Manager Code here" at the end of the file, please replace this line with your code.
- Alternatively, you can also transport the code with a plugin. However, this is usually an unnecessary step that only takes time. In addition, some of the plugins tend to slow down your WordPress site.
Integrate Google Analytics via the Google Tag Manager
Then it continues as follows:
$config[ads_text5] not found- Find your tracking code and the ID of your Google Analytics account.
- In the Google Tag Manager, click on "Tags" in the left menu and select "NEW".
- You will then be shown a range of services and products. You should find Google Analytics right at the beginning. Choose it.
- Then choose "Universal Analytics" as the tag type. Now you have to enter the ID of your Google Analytics account.
- Remember to anonymize IPs in order to comply with data protection.
- Select under "4." The option "Trigger on all pages", finally all sub-pages of your WordPress presence should be recorded. Then click "Create Tag".
- Overall, the integration of Google Analytics does not take long. It doesn't matter which of the methods you choose. Even beginners should master this task easily within two to three minutes.
About the author
Florian Kolbe works at Online Solutions Group as an online marketing manager. For him, dealing with SEO, SEA and the corresponding tools is part of everyday work.
$config[ads_text6] not found