analytics-code

How to set up Google Analytics and Google Tag Manager code in WordPress

WordPress is an open source content management system, it is easy to use and  there is a large selection of templates and plugins. WordPress is the most popular and most used CMS system. According to research, WordPress occupies almost 60% of the CMS market. In total of all web sites, WordPress is active on 25% of the market. On the other hand, it is important to have a Google Analytics implemented on your website because it is one of the basic tools to monitor user behavior and you can measure the success of your marketing activities on the Internet.

 

Since many websites use WordPress, this blog post will show you how to set up Google Analytics and Google Tag Manager codes on WordPress website.

First of all, you need to find and copy Analytics code. Log in into your Google Analytics account, click on the top of the bar on Admin. In the middle column (Property) click on Tracking Info and then on Tracking code. There you will find Analytics code that you need to copy on your website.

Google analytics code

There are many ways in which you can implement Google Analytics code in WordPress, but we will explain the two easiest and least painful ways, which allow the installation of code in the <head> tag, just as Google proposes:

1. Using a plugin – there is a lot of plugins that let you implement Analytics to WordPress site. But one of the easiest method is using the Insert Headers and Footers plugin.

For start, install and activate the plugin. Once you activate it, click on the left side on Settings and then on the Insert Headers and Footers. In the Scripts in Header field you need to paste Analytics code. After that, just click on blue button Save and you are done!

wordpress-plugin-insert-analytics-code

 

2. Directly in the code – WordPress contains Editor, which allows us to modify the code, which means we can actually implement Analytics code without using the plugin.

So, on the left side, click on Appearence and then on Editor. On the right hand of the Editor, find the file called Theme Header (header.php) and click on it. In the code find </head> tag, just paste Analytics code right before the closing </head> tag and click on blue button Update File.

analytics-code-insert-in-wordpress-header

These are two easiest ways to install Analytics code on your WordPress site.

Implementing Google Tag Manager code

Implementing Google Tag Manager code works in the same way as the installation of Analytics code in second step. Google recommends that the GTM code needs to be placed immediately after the opening <body> tag, so its better paste it directly into the code. So you need to go to Editor (Appearence->Editor), on the right side, find the file Theme Header (header.php) and click on it. In that file, find opening <body> tag and paste GTM code after it.

google-tag-manager-code-insert-in-wordpress

 

If you want, you can use plugin too. One of the best plugins is Duracell’s Tomi Google Tag Manager for WordPress. But be careful, some plugins implement GTM code in footer or header.

 

If the process isn’t entirely clear or you have difficulties with the implementation, we recommend to seek help from your developer.

Leave a Reply

Your email address will not be published. Required fields are marked *