'Cannot stringify dataLayer' when using Google Tag Managers 'click-listener' in angular-js app

1.1k Views Asked by At

We are trying to implement tracking via the google tag manager for an angularjs app. When using a click-listener defined in the tag-manager, the following script gets injected into the app on every click (or so it seems):

(function (a)
{
    var b = {}, c;
    for (c in a || {})if (a.hasOwnProperty(c) && "undefined" != typeof a[c])try {
        b[c] = JSON.stringify(a[c])
    } catch (d) {
        console.log("Cannot stringify " + c)
    }
    a = document.createEvent("CustomEvent");
    a.initCustomEvent("RetrievedVariablesEvent", !0, !0, {variables: b});
    window.dispatchEvent(a)
})({'studioV2': window['studioV2'], 'richMediaIframeBreakoutCreatives': window['richMediaIframeBreakoutCreatives'], 'dataLayer': window['dataLayer']})

When a click is tracked the "Cannot stringify dataLayer" error occurs. The reason for this is, that with the click, also the element is send which has a circular reference to itself, because of the child and parent references attached to the object (by jquery possibly??).

Any ideas how to implement a click-listener with the google tag manager, without running into this recursion?

1

There are 1 best solutions below

0
On BEST ANSWER

It turned out that the reason was the Chrome Extension Tag Assistant. After uninstalling it, the notification, as well as another bug went away.