Google Adsense (Onclick Event)

I am using Google Adsense and I was curious whether I can track user's IP address when they click on the ad. As I found out - I can't.

I have written a small code, which should record user info into the database when they click on the ad.

The problem is to trigger onlcik even on Google Ad (I can't do it for some reason).

<div class="google_add" style="clear: both;">
    <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-xxxxxxxxxxxxxx" data-ad-slot="xxxxxxxxxx"></ins>

    <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script>
</div>

My jQuery

$(window).load(function() {
    $('.google_add > ins').click(function() {
        // Ajax request 
        $.ajax({ 
            type: 'POST', 
            url: '/script/of/the/tracker.php'     
        });
    });
});

This doesn't work and for some reason and click even does not work.

I tied

setTimeout()

I tried using setTimeout() - maybe Google does not load fully and it cancels all events on their code - did not work as well.

onclick=""

I tried using onclick="" on of Google - did not work as well.

I don't really know why this problem happens, so please help and tell me if this is possible to do.

UPDATE

This is the jQuery library that allows to do what I was asking - .

SOLVED!

2
Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.