Custom Click Tracking for AdSense

I need to identify my users when I click on an ad. For example, when user A is online, I need to know what exactly he clicked on the ad unit.

When using my own ads, it was a piece of cake (using URL redirection) - however, now we plan to switch to Adsense, which displays the ad through javascript, so I can’t configure the redirection there.

How do I track - which user, which ad unit - in the case of adsense?

Thanks a lot.

- maku

+2
source share
2 answers

Even if there is no good way, but it is quite easy to do. First of all, put your adsense code in a div as:

<div id="adsDiv" class="adsDiv"> <!--here your adsense code--> </div> 

now in your jquery code use this:

 $(".adsDiv").on("click", function(){ setTimeout(function() { //here call to php function via ajax etc and in php you can easily check which user is currently online via session who clicked on ad. }, 5000); }); 

Please note that your php function will be called after 5000 ms, which means the user clicked and viewed your ad. You can increase or decrease it according to your needs.

0
source

Source: https://habr.com/ru/post/985840/


All Articles