Install Google Tag Manager in WordPress

Analytics Blog Growth Hacking Online Marketing
Install Google Tag Manager in WordPress

Last updated on March 16, 2018, 4:22 PM

As is often the case in WordPress, there are 2 variants. The manual variant in which you have to attack and change certain WordPress files, and the β€œplugin method” to install the Google Tag Manager in WordPress. The advantages of Google Tag Manager (GTM) have already been briefly explained here, and since there are actually only advantages, you should also use this wonderful tool :)

The plugin method for installing GTM in WordPress

There is a wonderful plugin called Duracell Tomi’s Google Tag Manager for WordPress that pretty much does all the work for you. When using this plugin you actually only need 3 steps:

  1. Search and install the plugin
  2. Activate the plugin in the WordPress plugin menu
  3. In the settings, click on β€œGoogle Tag Manager” and enter the Google Tag Manager Container ID (which you have to copy beforehand in the Tag Manager interface). install google tag manager in wordpress - freshestweb online marketing Agencyenter google tag manager id in duracell tomis plugin wordpress - freshestweb

The manual method to install Google Tag Manager in WordPress by modifying the header.php file

If you’re not afraid of fiddling with your theme’s header.php files a bit, then I recommend this method as it saves you having to use a plugin. The disadvantage here is that you obviously have to repeat this change if you change the theme. Here you first have to get the install code from the Tag Manager and copy it to a file or the clipboard.

You can find the install code in the GTM here:

Find GTM install code - freshestweb

and then

GTM google tag manager install code - freshestweb

There you take the code for the header and body area. This then usually has to be inserted into the header.php file using an editor (Design -> Editor). To be on the safe side, it’s best to save a version of header.php before making the changes. If you’re comfortable here, I would recommend this method. If not, the security option is probably the plugin method with the Duracell Tomi plugin :).

Once Google Tag Manager is installed cleanly, the next useful step is this overview of helpful Google Tag Manager features and how to use them.

We would be very happy about a review of the blog post :)