admin管理员组文章数量:1391934
I am working with a page that contains an iFrame using a system which seems written by aliens. The system was written many years ago in dotNet
framework.
I am trying to track a click event via a tag but I have noticed that when clicking the element in the iFrame, the console shows 2 elements being clicked and Tag Manager
shows 2 click events. The first element shown from the click is an element hidden at the top of the page, the second click is the element I clicked.
The HTML
is:
<input type="button" name="BOOK NOW" value="Book Now" class="platinum-book-button btn btn-primary">
In Tag Manager
I have set up a trigger as follows:
Trigger Type: Click All Elements
Trigger Fires: Some Clicks
Condition: Click Classes - matches CSS Selector - .platinum-book-button .btn .btn-primary
I then add in the console (as `CTRL - Click does not stop page changing):
document.addEventListener('click', function (event) {
event.preventDefault();
console.log(event.target);
}, false);
and console shows:
<input type="submit" name="ctl00$plcBody$BookingFormGrid$ctl04" value="BOOK NOW" onclick="$('form').attr('action', 'DetailsEntry.aspx?bfid=126b48d6-e3b9-4e57-8be6-067da3425467&bfpid=c125f99a-093c-402a-8855-436e7d233d74&bfrtid=bf8acbd4-78a1-4391-9972-3366c5405ce3&arr=2019-07-07&nts=5&a=1&c=0');WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$plcBody$BookingFormGrid$ctl04", "", true, "", "", false, false))" class="btn btn-primary bnow">
<input type="button" name="BOOK NOW" value="Book Now" class="platinum-book-button btn btn-primary">
The first element is hidden at the top of the page and not the element I have clicked. The trigger does not fire as the click classes condition is not met.
What have I missed?
I am working with a page that contains an iFrame using a system which seems written by aliens. The system was written many years ago in dotNet
framework.
I am trying to track a click event via a tag but I have noticed that when clicking the element in the iFrame, the console shows 2 elements being clicked and Tag Manager
shows 2 click events. The first element shown from the click is an element hidden at the top of the page, the second click is the element I clicked.
The HTML
is:
<input type="button" name="BOOK NOW" value="Book Now" class="platinum-book-button btn btn-primary">
In Tag Manager
I have set up a trigger as follows:
Trigger Type: Click All Elements
Trigger Fires: Some Clicks
Condition: Click Classes - matches CSS Selector - .platinum-book-button .btn .btn-primary
I then add in the console (as `CTRL - Click does not stop page changing):
document.addEventListener('click', function (event) {
event.preventDefault();
console.log(event.target);
}, false);
and console shows:
<input type="submit" name="ctl00$plcBody$BookingFormGrid$ctl04" value="BOOK NOW" onclick="$('form').attr('action', 'DetailsEntry.aspx?bfid=126b48d6-e3b9-4e57-8be6-067da3425467&bfpid=c125f99a-093c-402a-8855-436e7d233d74&bfrtid=bf8acbd4-78a1-4391-9972-3366c5405ce3&arr=2019-07-07&nts=5&a=1&c=0');WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$plcBody$BookingFormGrid$ctl04", "", true, "", "", false, false))" class="btn btn-primary bnow">
<input type="button" name="BOOK NOW" value="Book Now" class="platinum-book-button btn btn-primary">
The first element is hidden at the top of the page and not the element I have clicked. The trigger does not fire as the click classes condition is not met.
What have I missed?
Share Improve this question asked Jun 23, 2019 at 1:03 TheRealPapaTheRealPapa 4,5399 gold badges80 silver badges165 bronze badges1 Answer
Reset to default 5I ended up using
Trigger Type: Click All Elements
Trigger Fires: Some Clicks
Condition: Click Element - matches CSS Selector - [name="BOOK NOW"]
本文标签: javascriptGoogle Tag Manager Click Classes Event not workingStack Overflow
版权声明:本文标题:javascript - Google Tag Manager Click Classes Event not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744678280a2619246.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论