Technical Marketing Guide

A travel guide for technical marketing – get inspired and start exploring yourself.

Installing Google Tag Manager in WordPress

For the basic Google Tag Manager setup you’ll just need to place the „container-snippet“ on every page of your website. A website is typically structured in a way that allows you to place the code in one file which results the code to be shown on every page of the website. In wordpress this file is the header.php.

There are a couple of ways how to do the implementation. The two pieces of code you’ll need to put on your website should be located right after the opening <head> tag and after the opening <body> tag. As described in the Lesson about WordPress Child-Themes you don’t want to edit your master theme but rather make the adjustment in your child theme. I’ve recorded a quick video of my recommended implementation.

Code you’ll need to place into the header.php of your WordPress Theme:

<?php do_action('after_head_open'); ?>

<?php do_action('after_body_open'); ?>

Code for the functions.php file:

add_action('after_head_open',  'insert_gtm_head');
function insert_gtm_head() {
?>
<!-- Insert Code Here -->
<?php
}

add_action('after_body_open',  'insert_gtm_body');
function insert_gtm_body() {
?>
<!-- Insert Code Here -->
<?php
}

I do like to do those things myself, this is part of the whole idea of being a technical marketer. You could very well just use a wordpress plugin – but – be aware of big overbloated plugin, they might have some tracking code in them … they get code-access to your website so you should just be careful. For the Google Tag Manager implementation I can recommend Google Tag Manager. It seems very lightweight and doesn’t contain any unnecessary code.

Next Post

Previous Post

Never miss another guide, sign up now

Cookie Settings

© 2018 Technical Marketing Guide | Imprint