Profile cover photo
Profile photo
Andy Scott
Digital Analytics Guy
Digital Analytics Guy
Andy's posts

Post has shared content
So many good helpful.
100+ Google Tag Manager learnings

In my latest article, I've compiled 100 short tips / learnings I've accumulated over the years. Some of them are simple and obvious, and some are more obscure things you only learn when running into them head-on.

#gde #googletagmanager #blogpost

Post has shared content
What is the best way to return a default value if a GTM variable is undefined?

I looked on Stack overflow and there seems to be a wide variety of ways to check for undefined, but nothing thats concrete.

Here is my go from within a custom HTML Tag:

var searchCatFromGTM = {{searchCategory}};
var searchCat = searchCatFromGTM == undefined ? "No Category Defined": searchCatFromGTM;

Any better way to do this?

Post has shared content
holy crap this is exactly what i wanted to do the moment both arrive

Post has shared content
Just sharing my generic GTM containers templates/recipes...

The generic login for these is:
password: philrulesgtm8

Or if the login does not work you can import using these links...

Generic CMS:

Wordpress (mapped to GTM for Wordpress)

Magento (mapped to Qubit dataLayer)

Drupal (mapped to plugin)


Angulartics (mapped to plugin)

AMP (new)

APP - iOS FireBase (new)

APP - Legacy





Post has shared content
Critical knowledge right here
10 JavaScript Concepts for Web Analytics Implementation

Anyone working with the web should have a working knowledge of JavaScript. There's no excuses! If you happen to work with web analytics, I dare say there's no other more important technical skill.

In this article, I list 10 JavaScript concepts which I consider absolutely vital for anyone working with analytics implementations to grasp.

#gde   #blogpost   #googleanalytics   #googletagmanager  

Post has shared content
Container Snippet placement recommendation now officially changed to <head>

FINALLY! The recommendation for where to put the Google Tag Manager container snippet has changed. The official word is now to put it in <head>.

This is significant, because <head> is the correct place for all asynchronously loading libraries, but GTM's documentation had been steadfast in recommending it to be placed in the beginning of <body>. With this change, the library will start loading earlier in the page load sequence, and as a result your tracking accuracy will improve.

If you want search console verification to still work, and if you care about JavaScript-less users, you'll need to leave the <noscript></noscript> block in the beginning of <body>.

H/T +Scott Herman

Post has shared content

Post has shared content
Want to start tracking hover events with Google Tag Manager? Download our new GTM recipe and learn how to start tracking with this guide.

Post has shared content
Currently in a back and forth with a client about adding GTM's javascript container tag to the <head> instead of opening body. Keeping my own opinion silent (for the moment).

Of course, I thought that this forum would be a good place to poll some of my expert friends. Especially +Brian Kuhn. :-)

What say you? Should GTM's javascript run from the <head> or <body>?

Post has shared content
Optimizing Variables

Anyone have best practices for optimizing a large container, particularly its variables?  I have a container with 250+ variables, 60+ triggers and 50+ tags.  I'm comfortable with optimizing tags, but I don't totally understand how/when variables are resolved.  I have three main questions:

First: ~100 of those variables are constant custom dimension slot numbers for GA.  Are those getting resolved and re-resolved with every event, if they're only used inside my GA tags?  If so, would it notably lighten/speed up my container to replace them in the tags with their values, and do away with the variables entirely?

Second: I'm rewriting page URLs before I send them to GA, and using a fairly hefty custom javascript variable to do so.  Since this only needs to execute when the page loads, would it be helpful to put an "if ({{Event}} == 'gtm.dom'", or something similar, around the variable, to limit how often it's resolved?

Third: I also have a large number of dataLayer variables.  Would it be more efficient to just set up a single variable pointing to the dataLayer itself, and then access its values through that variable - or do I really need a single dataLayer-type variable for each dataLayer key?

Thanks in advance for any help!

Wait while more posts are being loaded