Iโm not quite sure if this is allowed by AdSense, since you can abuse the system by tracking clicks on ads (for example, blocking content). In addition, you will come across different cases of edges - like the one you asked - why I usually recommend you the following:
What you probably want to do is connect Google Analytics to AdSense (it's as simple as 1-2 clicks) so you can easily go to the publisher โ AdSense in the Google Analytics toolbar to see impressions, clicks, and more AdSense data. You can always create your own reports that can access this data.
If you really want to track clicks, you can check out this iframe tracker that uses event blurring to determine which element / iframe the mouse cursor is currently hovering over.
source share