datalayer google tag manager

落花浮王杯 提交于 2020-01-06 03:22:13

问题


Iam using google tag manager it's going very well with click events but when I tried to use datalayer it's not working here is my datalayer

   <script>
$('.tag').click(function(event){
    dataLayer.push({
        'event':'myNewTransaction',
        'eventCategory': 'App', //create a datalayer variable macro called eventCategory
        'eventAction': 'Click', //create a datalayer variable macro called eventAction
        'eventLabel': 'iOS' //create a datalayer variable macro called eventLabel
    });
});

And in the console when I click on the element with class 'tag' I get this message Tag Not Fired On This Page and this is the message when firing triggers

Event equals myNewTransaction

_event equals My New Transaction

Please help


回答1:


For click events, you should try to stick to using the default click and link click listeners (gtm.click and gtm.linkClick), and then triggering your tag to fire based on the clicked class or even the clicked text. It's not as efficient using the dataLayer when you can use what is already built-in. That said, if for some reason you still need to use the dataLayer, then

  1. your code looks fine,
  2. you should create a Custom Event trigger with the value of the event as "myNewTransaction"
  3. your tag should fire based on this custom event trigger

If you still have issues, then please post screenshots of your tag and trigger configurations.



来源:https://stackoverflow.com/questions/38816513/datalayer-google-tag-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!