1

I am running into a problem, and I cannot seem to find a fix for it. The situation is as follows the marketing department wants to integrate GTM. Which is fine as they want to have full control over the different third party providers they wish to integrate. But for this to happen they would like to have the ability to track all clicks on a page.

And they came back to me that currently no click events are being tracked with the current configuration within GTM. At first the thought was that events were not propagating (bubbling) upwards. But having tested this myself by binding a event listener to the document (click) (see below) all div, buttons etc. with an ng-click directives did reach this handler without problems.

document.addEventListener("click", function(event){
    console.dir(event.target);
});

So my assumption was that there was something wrong with the configuration but after looking at the configuration (one I created myself which looks as follows):

enter image description here

I still could not get it to work. Buttons that already use angulartics - https://luisfarzati.github.io/angulartics/ to send an event to the GTM container work as expected:

<a href="file.pdf" analytics-on="click" analytics-event="Download">Download</a>

Only the catch all click events (or any filter on it like purely looking at button clicks) does not. Now after looking at it a little more it seems GTM expects the gtm.click _event to happen. But I can't figure out (gazing through the gtm.js file) how they bind to all click events within the document (there is a click binding on the document after initialization but I am unsure if this is GTM or something from angular). And even if so I have placed many breakpoints within this file which seemingly could be related to it but none of them triggered when something was clicked.

So my question is, has anybody got experience combining angularjs with angulartics and GTM while having it catch all click/touch/mousedown etc. events and send these to GTM?

4

2 回答 2

1

确保在进行一些更改后发布了 GTM 容器。使用 GTM 界面(右上角)内的“立即发布”或“预览和调试”按钮。因为根据您的标签配置,每次用户点击网站上的某些内容时,该标签都会触发。

关于“gtm.click” - 当用户点击网站上的某些内容时,每次都会触发此 GTM 事件。在屏幕截图中,您可能会看到,当用户在网页上单击某些东西时,当 GTM 单击侦听器打开时(如在您的标签中),它在 GTM 调试模式(“预览和调试”)下的样子。

在此处输入图像描述

可能是我网站上有关在 GTM 上跟踪按钮/链接的一些相关文章也会对您有所帮助:

http://konygin.net/gtm/tracking-links-en/

http://konygin.net/gtm/tracking-buttons-en/

于 2016-01-06T11:17:54.230 回答
0

我的问题原来是给我html GTM标签(noscript / script)的人(来自营销)没有正确复制它(或者当它粘贴到JIRA中时出现问题)。在我直接复制它之后(可以访问 GTM 管理面板),它就像我期望的那样工作。

看到我通过尝试只有一个 index.html 来调试它,其中只有一个按钮。即使在那个时候,跟踪器也没有工作,我开始怀疑为什么会发生这种情况,因为不再有可能导致问题的角码。

吸取的教训,下次需要时自己复制代码以确保它不会在此过程中被损坏:/

于 2016-01-06T15:22:41.980 回答