Detect if someone is blocking Google Analytics or Google Tag Manager

These days the use of adblocking tools is growing fast. These tools aren’t always used only blocking the ads, also analytics software is blocked sometimes.

Browser extensions like Ghostery and uBlock are used to get rid of all those trackers. Why wouldn’t a non-marketer disable all the found tracking software? With a couple of clicks someone has disabled 2000 trackers.

Schermafbeelding 2016-01-30 om 12.41.32

Continue reading Detect if someone is blocking Google Analytics or Google Tag Manager

Track Hotjar in Google Analytics with GTM

Everyone who knows Hotjar, knows how excellent this tool is. In this blogpost I would like to explain how you could track Hotjar visitors in Google analytics using a custom dimension. There are a lot of reasons why you would like to do this. But the main reason is that it combines the best of both. Google Analytics extends Hotjar and vice versa with additional data for each visitor.

Every time a new visitor visits your website Hotjar sets a cookie called _hjUserId. Hotjar describes the function of this cookie as follows:

This cookie is set as soon as a user loads a page which contains the Hotjar code. The cookie contains a universally unique identifier (UUID) which allows Hotjar to track the same visitor across multiple pages and sessions.

Whooops, Hotjar has updated their script a bit. They are no longer storing this information in a cookie. We have to make a slight customization.

An example of an overview of Hotjar user id’s and their recordings. There could be multiple recordings for one user.

hotjar user ids

Continue reading Track Hotjar in Google Analytics with GTM

Create an exit popup with the Google Tag Manager

These days when you are browsing the web, many websites are using popup boxes to turn you into a newsletter subscriber when you are leaving the page. There are many tools on the web who provide this conversion booster. An example is SumoMe.  Unless it’s free, they serve a link to their website.

In this blogpost I am going to explain how we could use the Google Tag Manager to show up a popup box for leaving visitors. Turning leaving visitors into newsletter subscribers is the goal of this blogpost.

Inspired by this blog post, i have created my own (extended) version. It also handles saving the posted data to the database. Maybe it is a bit complicated, but i have tried my best to keep it as simple possible.

An example of what we are going to build:

previewpopupbox

Continue reading Create an exit popup with the Google Tag Manager

Track the use of AdBlock in Google Analytics

As a publisher that is highly dependent on ad revenue, it is important to know how many people are blocking your ads with a browser extension as AdBlock. It it possible to track how many users are using this software in Google Analytics with some help from the Google Tag Manager.

The trick is loading some Html which is blocked by AdBlock. With some Javascript we detect if this Html is blocked whether or not.  I have used a solution that is mentioned on Stackoverflow.com.

First we have to create a new Custom Html tag. Inside it we have our fake Advertisement.

After this we include jQuery, and our script to dectect if our fake advertisement is shut down by determining the height of our div.

Continue reading Track the use of AdBlock in Google Analytics

Track outbound link clicks in Google maps

It is possible to track outbound links inside a Google maps map. Therefore it’s important you don’t use the embed functionality Google offers by default.  This creates an iframe with a Google maps map without your Google tag manager code.

A solution is loading Google Maps with the Google API loader. Here’s an example how to use it:

Continue reading Track outbound link clicks in Google maps

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