: Using Google Analytics to track events that happen in an iframe I'm trying to track how many visitors click on a button in our site. The problem is the button is located within an iframe
I'm trying to track how many visitors click on a button in our site. The problem is the button is located within an iframe coming from an external service.
Here is the page in question: www.anoisewithin.org/support-us/individual-giving/#tabs-7
I would like to be able to measure how many visitors click the Search button in the iframe, but I am unable to append any Google Analytics tracking code to the button. Is there any other way I can track that particular click event?
More posts by @Welton855
1 Comments
Sorted by latest first Latest Oldest Best
Since the search button is within the iframe's code located on the hepdata.com domain, you would need access to the source code on that site in order to add tracking code that you can use on your site, by setting the document.domain property or using cross-document messaging.
If you don't have access to the code on that site, you might try positioning a transparent image in your code over the search button in the iframe, and on the image hover event have it trigger JavaScript to run the tracking code and then hide itself so the user can click on the underlying search button. This is dependent of course on if the search button will remain in the same position in the iframe's layout, and JavaScript is enabled in the user's browser.
Other than the above, there isn't much else you can do to track click events within an iframe because of the cross-site scripting security implemented in browsers to protect JavaScript exploits from other domains.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.