Profile cover photo
Profile photo
Andy Scott
Digital Analytics Guy
Digital Analytics Guy

Post has shared content
After searching various corners of the Internet, I've compiled a list of ready-to-use JavaScript code snippets for Google Tag Manager (links to GTM recipes or blog posts). Let me know if you notice something missing. This list/collection is far from complete.

Happy tagging!
Add a comment...

Post has shared content
Hi All,

We have a product array in the data layer on a search results page. Within this array, we have the product name, product ID and product price.

Question - We have a 3rd party HTML script that needs to collect the product ID's of all the products in the array. How would I go by creating a variable to only show all the product ID values within the array?

The Facebook pixel is a good example, where you need to pull in numerous content ID's.

Any help would be appreciated.

Add a comment...

Post has shared content
A useful resource (especially for beginners) - Google Tag Manager Glossary (with more than 160 terms). You can also download it as PDF.
Add a comment...

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
Add a comment...

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?

Add a comment...

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

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




Add a comment...

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  
Add a comment...

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
Add a comment...

Post has shared content
Wait while more posts are being loaded