To check how the current page preforms in the Google Structured Data testing tool you could easily click this bookmarklet:
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:
A simple Bookmarklet to mark all header tags on a page. To use it: Drag this link to your bookmarks. Give it a usefull description. And test it by clicking it!
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.
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.
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:
First create a new Custom Html tag and support document.write.
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:
var cookieName = "nameOfTheCookie";
var cookieValue = "value";
var cookiePath = "/";
var expirationTime = 2628000; //For example one month in seconds (2628000)
expirationTime = expirationTime * 1000; //Convert expirationtime to milliseconds
var dateTimeNow = date.getTime(); //Get current time in milliseconds since 1 january 1970 (Unix time)
date.setTime(dateTimeNow + expirationTime); //Set expiration time (Time now + one month)
var expirationTime = date.toUTCString(); //Convert milliseconds to UTC time string
document.cookie = cookieName+"="+cookieValue+"; expires="+expirationTime+"; path="+cookiePath; //Set cookie
Everyone who works with the Google Tag managers knows that editing code in the Custom HTML Tags for example is
very anoying. Update: There is a code highlighter available inside Google Tag Manager now! If it does not fit your needs you could fall back on the code editor mentioned in this blogpost.
When you are testing your new Google Tag manager tags it could be very usefull if you could customize the value of your cookies. The default way is deleting the cookie and set it again. This is a very time wasting method and not always give the right results.