Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Track Google Adsense click with JavaScript

What I am trying to do is to track the user's click on a Google Adsense. There are two types of ad's being generated by including the Google Adsense script tag.

  • An imagebanner (a single click on the banner will redirect the user to the ad)
  • A banner with one or more links (the user has to click on the link to get redirected)

I have issues with the second type of the banner.
The link comes within two iframes. It's pretty easy to track the click if the user's mouse is on the outer iframe. But I actually can't access the second iframe to track the click if the user clicks on the link ( tag). So if the user clicks on a whitespace in the banner, my function also counts it as a click. The reason is quite obvious: Google denys it.
I don't want to manipulate Google's code, I just want to track the click.

like image 823
spyfx Avatar asked Jan 14 '15 20:01

spyfx


People also ask

How does Google AdSense track clicks?

Analytics does track clicks, impressions, and earnings for your AdSense for content ad units. This includes both text and image ads shown through AdSense for content. Analytics does not track search boxes or any other AdSense products.

Does AdSense track IP?

Google's advertising services don't use IP addresses to track visitors, but they do use a visitor's current IP address to help select ads.

Can I self click on AdSense?

Yes, you're welcome to view your own pages without generating invalid impressions. Simply viewing your pages yourself will not jeopardize your good standing in the AdSense program - however, please continue to avoid clicking on any ads, and don't reload your pages excessively.


1 Answers

I'm not quite sure whether this is allowed by AdSense since you could abuse the system by tracking clicks on ads (e.g. content locking). Additionally, you will encounter different edge cases – like the one you asked – that's why I generally recommend you the following:

What you probably want to do is connecting Google Analytics with AdSense (it's simple as 1-2 clicks) so you can easily navigate to Publisher → AdSense in the Analytics Dashboard to see impressions, clicks and other AdSense data. You can always create custom reports which can access this data.

If you really want to track clicks, you can checkout this iframe tracker which uses blur events to determine which element/iframe the mouse cursor currently hovers.

like image 67
Luca Steeb Avatar answered Oct 26 '22 16:10

Luca Steeb