Reputation: 4539
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?
Upvotes: 4
Views: 7421
Reputation: 4539
I ended up using
Trigger Type: Click All Elements
Trigger Fires: Some Clicks
Condition: Click Element - matches CSS Selector - [name="BOOK NOW"]
Upvotes: 5