Custom Javascript

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
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