How to programmatically know if an Google AdSense ad is successfully displayed or if any error occured in my react/next.js website?

1.3k Views Asked by At

Our site let's user post content and we display ads on them and share some part of ad revenue with user just like YouTube. Now the issue is how to programmatically know if an ad was successfully displayed on user's post? We want to count the number of ads successfully displayed on user's post so that we can share the revenue accordingly. Are there any functions like onAdLoadSuccess(), or onAdError() etc so that we can write our own logic inside these functions to maybe save totalAdCounts in a database?

1

There are 1 best solutions below

1
Mikita Belahlazau On

You can use data-ad-status to detect whether given ad slot has been filled. It's the closest variant to onAdLoadSuccess() adsense has: https://support.google.com/adsense/answer/10762946?hl=en