Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect google ads click

I have gaming commmunity forum, where i installed some Google Ads, but people are abusing it (out of their good will ofcourse) and clicking them constantly...now i don't want to generate any illegal clicks to the site, but some people just are not listening.

Is there any way to detect if someone has clicked google ads...so i could disable them for the use who has clicked them for a day or so.

Thanks for you help.

like image 690
Ardi Vaba Avatar asked May 01 '11 17:05

Ardi Vaba


2 Answers

If I recall correctly - it's against Google Ads rules for you to track ad clicks, because it leads to providing incentives for clicking the ads. (such as disabling them). I realize you're trying to fix the illegal clicks issue, but you're in fact digging your own grave.

But to answer your question with purely web-dev interest - you can detect the mouse X Y position (+ page scroll offset) in window.onbeforeunload and quickly ping your server. Usually this is done by creating a new Image(); with the source being a php file.

This is accurate for all browsers, regardless of iframe usage.

Good Luck!

like image 190
Mikhail Avatar answered Sep 28 '22 02:09

Mikhail


Google ads are iframes and Javascript does not have access to the contents or adding events to it if it's on a different domain then the parent site (see the law of iframes here).

You can, however, place a clear div (visibility: hidden, not display: none) over the iframe and, in a way, intercept the clicks to it. The only issue with this is that you either intercept the click or you don't. So when the user clicks the first time you can run your logic on whether to allow it or not, and if you want to allow it, display: none your div and prompt the user to click again.

This is pretty much the only way you can do it.

like image 29
Mauvis Ledford Avatar answered Sep 28 '22 03:09

Mauvis Ledford