We are trying to send a Google Analytics event from a booking form that is within an Iframe when the Book button is clicked. In order to accomplish this, we need to figure out a few problems.
- Getting the site to recognise a click within an iframe
- Checking the element that was clicked is the Book button
- If so, sending the Analytics Event to GA
We have already tried a few methods found online, including:
Detect Click into Iframe using JavaScript
https://www.tutorialrepublic.com/faq/how-to-detect-click-inside-iframe-using-javascript.php
https://codecorner.galanter.net/2015/12/22/detect-iframe-click-from-parent-page/
But unfortunately none of these solutions have worked for us.
The very minimum we're expecting from following solutions we've found online has been that we can simply log something in the console when an element within the iframe is clicked, but none of the attempts have logged anything.
If anyone has an idea about any of the steps, even if it's just getting the site to recognise the click, it would be appreciated.
Thanks
EDIT: We control and are able to modify the code that's being called within the iframe