Google Tag Manager

Install Facebook Pixel through Google Tag Manager

Adding the Facebook Pixel through Google Tag Manager

For many companies, social traffic is very important. And there is one behemoth in the playground; Facebook. There are some great ways to use a Facebook Pixel in order to start measure conversions and optimize adverts you’re running on the platform. Not only that, the pixel allows you to create audiences for remarketing as well. That opens up for a really good targeting on Facebook for your audiences.

In order to start using the pixel you’ll have to create it using the Ads Manager.

Read More
Track Main Menu Clicks in Google Tag Manager

Track main menu usage on your site with GTM

A very common thing that I setup tracking for on a variety of pages for different companies is how their main menu is used across the site. The main menu is usually where most of your visitors will look at if the page they landed on didn’t really hit the mark. That’s if you’re lucky, otherwise they’ll just hit the back button at go back to what ever Google search that led them to you in the first place.

Sites usually invest some thought in the navigation and by that it’s of course important to measure how your site’s visitors will use it. In Google Analytics you can of course see how many of your visitors that looked at, say your Product Overview page. You can also see how many of them that came from, say the start page or a specific product page. But you can’t really see how many that used your sites navigation in order to from one page to another.

Luckily, you can set up tracking on that using Google Tag Manager in basically a few minutes.

Read More
Hotjar and Google Tag Manager

How to add Hotjar via Google Tag Manager

If you haven’t already heard about Hotjar, you should really take a look at it. The tool doesn’t only allow you to create heatmaps, but allows you to view things as scroll depth, create funnels and ask your visitor questions. And it also allows you to view recordings of visits to your pages, which is a feature I really love.

And since Hotjar requires you to add its script on the page, why not do it via Google Tag Manager? That is really the purpose of using a tag management system, right?

Once you have your account setup, you will get a tracking code that looks like the one below that you need to insert on all pages on your domain.

Read More
Remove Query Strings with GTM

Remove URL query string via Google Tag Manager

A few days ago I was looking at the tracking for a hybrid iOS/Android app where the Apps appended a query string to the URLs in app. Given this, I had two versions of each URL in Google Analytics, looking something like this:


The first one is the URL that is being used on the desktop version of the site, no matter of you are browsing with a laptop, mobile phone or tablet. The latter one is the URL being used if you open the link from within the app on your phone.

An easier way of doing this is probably using rewrite filters in Google Analytics, but since I want to do most things in Google Tag Manager this is how I solved the issue, taking into account that we don’t want to get rid of the query string in its entirety but only that part.

Read More

Measure how many of your visitors that are using Adblock

!!! POST UPDATED 2016-09-28 – With new screenshots adapted for the newest version of Google Tag Manager !!! 

More and more people are using some kind of Adblock in order to minimize the amount of ads they see online. According to a recent studie released by Pagefair shows that there are now 198 million active adblock users in the world.

The same study shows that ad blocking grew with 41% globally in the last 12 months.

I started doing some data collection based on this before summer, because people started talking a lot about it back then. I now have data enough (yea, I could blame vacation time too) to draw some conclusions based on it, but also share my implementation with you guys.

Are you interested in knowing how many of your visitors that are using any kind of adblocker while visiting your site?

Even though you maybe not are showing ads on your own site, there is a big chance that you are doing advertisement on other sites, and it is always good to know if your target audience are receiving your ads at all, or not.

Read More

Track file downloads with Google Tag Manager

If you have files for download on your site, I’d guess that you’d want to track if people are downloading them? Fear no more, with just a few minutes work in Google Tag Manager you’ll be set. The end goal here is to make sure that we track the appropriate file types and then send that information onto Google Analytics with an event.

This will make use some simple Javascript, but do not fret, I’ll walk you through it.

The first thing you need to figure out is if you have any odd filetypes on your site, other than the regular stuff. If that’s the case, just make a note of them because you’ll need to adapt my code later on.

Read More

Send an event into Google Analytics using GTM when a visitor copies text from your page

We all want to measure our pages in the best possible way, and I’m always trying to figure out how to lower the bounce rates where applicable. One of the things that visitors to your page can do is to copy some text, in order to send it in an email, to use it when sharing something on social media and so forth. And if a visitor is actively copying text from a page, that’s interaction to me.

So how can we possibly know if a visitor to your page as copying some text or not?

Well, it’s actually pretty easy. And using Google Tag Manager we can easily pass this information onto Google Analytics and start measuring what pages on your site people are copying stuff from.

Read More
Google Tag Manager and Contact Form 7

Contact Form 7 on WordPress with Google Tag Manager

Just the other day, I was holding a lecture for some students studying web analytics here i Stockholm. I was there to talk about Google Tag Manager and after some hours I received a question we looked into.


How do I send a Form Submit to GTM via the Contact Form 7 plugin in WordPress?

This is actually very easy to achieve, and I’ll walk you through both ways of doing it right here. Both with a GTM Plugin in WordPress, and without.

Read More
GTM/GA Tools

Top 5 debugging tools for Google Analytics and Google Tag Manager

Working with Google Analytics and Google Tag Manager often requires a lot of debugging. In order to actually verify that the things we are about to implement or that already are implemented are working or not, there are some really good tools that can help you with your debugging.

1. The Console (Google Chrome)

One of the tools I really can’t live without is the console in Google Chrome. It’s found under the Development Tools and can easily be accessed by pressing Cmd+Opt+J (Mac) or Cmd+Shift+J (Win).

Debugging via the console in Google Chrome

Since GTM is heavily dependent on Javascript, it is really invaluable to be able to take a deep dive into the inner sanctum on what’s really happening in the DOM and the dataLayer.

Read More

Rewrite a fragment based URL with Google Tag Manager for better Site Search in Google Analytics

Phew, that is possibly the longest title I’ve ever written, but there’s always a first for everything. Today we are going to have a look at a scenario where I found the URL used while doing a site search on a site wasn’t really optimal to push into Google Analytics.

In my case, the URL looked something like this after performing a site search on the site.

I of course wanted to push this data as a Site Search query into Google Analytics but also take the actual category as a parameter. After some initial discussion with the clients IT departement they figured that they had to rewrite the entire search function which would take a lot of time. This is what I did in order to solve the issue directly in Google Tag Manager instead.

Read More
Page 1 of 212