One of the services we offer here at stickee is a white label mobile phone comparison service. We are in the process of rebuilding and modernising this service so that all the websites can run on one back end and off of a single code base. That means, multiple websites will need to run on a number of different domains. That makes deploying and administering Google Analytics a little bit of a challenge. We wanted a simple way to install and configure Google Analytics across multiple sites. Google Tag Manager (GTM) takes most of the pain out of installing GA but we didn’t want to have to set up and install a new GTM container, GA tag, and event tracking, every time we spawn a new front end on a new client domain.
Fortunately, there is a solution. The lookup table variable type in GTM makes this a doddle. We set up a single GTM container common to all the storefronts, and then – by using a lookup table and the built in {{Page Hostname}} GTM variable – we built a lookup table like this:
GTM will detect the domain name it’s running on and look up the corresponding GA account number. It will then pass this value to a new variable that’s available to tags and other variables.
So, if we set up the standard Analytics tag in Tag manager to use that variable like this:
And set up all our event tracking like this:
All we now need to do to add Analytics and our custom event tracking to a new website is add a new row to the lookup table which takes seconds rather than having to create a new container and re do the whole process every time. Also, this method requires no coding or access to files and is version controlled so it can be handled entirely by the product team.