Change Html with Google Tag manager

When you would like to change the content or styling of your website, it’s possible to affect them with the Google Tag Manager. There are several Javascript functions that help to solve this.

There are many reasons why you would like to do this. Based on user interaction you could serve for example a custom alert or show a popup box to get new newsletter subscriptions. Or if you would like to A/B test with the Google tag manager, you could change colors and styling after reading this article. These are just two examples of usage, the possibilities are endless.

In my example, I’m going to change the styling of this blog post after a user clicks on a link. Use your own trigger to make it fit in your setup.

Add a new Custom Html tag to GTM:

ChangeHtml

Continue reading Change Html with Google Tag manager

List 404 errors + referral in Google Analytics with the Google Tag Manager

To track every 404 error on your website in Google Analytics you could use GTM in combination with jQuery. When a 404 error occurs we could register an event in GA.

We have to track occurring errors on every page. Therefore, we could create a new Custom HTML tag.

Track Http errors

Continue reading List 404 errors + referral in Google Analytics with the Google Tag Manager

Track outbound link clicks in Google Analytics with GTM

The Google Tag Manager gives you the possibility to track every click on your website. When you would like to know which outbound link clicks gets most of your traffic it is useful to save every external link click as an event in Google Analytics.

We need the GTM built-in variable Click URL to check if our outbound link meets our conditions. We have to activate this first.

built-in variables clicks

Continue reading Track outbound link clicks in Google Analytics with GTM

Track calls from Google Adwords or other sources with GTM

There are severall tools on the internet that gives you the possibility to track phone calls from visitors that are entered via Google Adwords or other channels. The disadvantage is that they are generally not free. You could use the Google Tag manager to serve a different phone number to vistors from a specific source. Each call made to this phone number is dirived from Google Adwords. With this technique you could manually track Adwords phone calls.

The way we could fix this is, is editing all the phonenumbers on your site. We will replace them with a new phonenumber. It is necessary that each phone number has the tel: prefix in the href attribute. For example: <a href="tel:0612345678">0612345678</a>.

First create a new Custom Html tag and support document.write.

changePhoneNumber1

Continue reading Track calls from Google Adwords or other sources with GTM

Set a cookie with the Google Tag Manager

It is possible to set of edit (re-setting) a cookie for storing information during a vistor session.

Create a Custom Html Tag with the following code:

Continue reading Set a cookie with the Google Tag Manager