Categories
Web analytics

CustomTask GTM GA debugging

Simo Ahava has a customtask generator, a  great thing, it combines his becoming an article about customtask in Google tag manager into one user-friendly generator.
I added a few improvements…

Remove the .forEach function

In what?

Remove PII from Hits   , it is a function in CustomTask, which if it encounters that in the URL or GA parameters there is an email, or other personal data defined via a regular expression, it will replace them with a placeholder. This change will not violate Google Analytics, to which personal information may not be sent.

What would I change?

.ForEach function

I would replace it with the classic ” for ” function .

Why?

EI 11 does not support the .forEach function . Classic for is even faster 😉,

Catching errors in CustomTask

Mistakes make me wonder what’s going on, what’s wrong.
Each time you use try {…} catch (err) {…} it has a chance to know the error message. So why not do it?
In the last lines, customTask is a clue if something happens.

And just expand it by sending more information via the standard dataLayer.push event to Google analytics.

One of the bugs you will discover is the previous one, with Internet Explorer 11.

.