I have an ad iframe being written onto my page dynamically. The advert inside may have another iframe itself and will "suck" click events through into it so cannot track them easily. I've used this great plugin by @Vince in the past:
https://github.com/finalclap/iframeTracker-jquery
which seems to work fine until the window this is all running in IS ITSELF an iframe and focus is somewhere on the outermost page. I can see it getting the rollover/rollout events but it doesn't get the click unless focus is somewhere inside the first iframe's window.
Has anyone found a solid way to do this? Thanks in advance if anyone can help.
One way to do this without writing lots of javascript detection click logic would be to have the advert on the page and the clickable link links back to your site. Updates a counter and then redirects them to the target page.
The above is just a different way of thinking about it. Plus it will still work if they don't have javascript enabled.
I think you can't do that using Javascript because of the same origin policy.
My iframeTracker plugin uses a crafty workaround to detect click on iframe, based on mouse and focus events, that simply doesn't work with multiple nested iframes.