0

I have a division containing AdSense code. The Adsense code writes code for an ad to the division. This code then creates an ad; or it creates a blank space the size of an ad; or it leaves the space blank while creating no space for an ad.

Previously one could could deal with the later two unwanted outcomes via a setting in your Adsense account which allowed you instead opt for a backup ad. This feature has been removed by Adsense.

It is impossible to dynamically determine if the ad is to be rendered or not by examining the innerHTML delivered by Adsense - its the same for all cases.

As my website uses a pure white background is there any way I can dynamically grab a screenshot of the division as rendered in the user's browser and then use a double loop to scan for any pixels that are not white. Any non white pixels would cause the double loop to exit as this means there is an ad. If no non white pixels were found this would mean no ad was rendered and a backup could be delivered.

If this was a programming environment like Xojo it be easy to dynamically create a picture in memory, use a double loop to scan through each pixel to look for any nonwhite pixels and then take a appropriate action if such pixels were found or not.

One cannot simply grab the division's innerHTML and try to create a image in a canvas and examine that since that would violate AdSense's terms and it would be a useless test as that does not test if the ad was actually rendered at the time the user requested the page.

Essentially one would be creating a screenshot of the division as it appears in the user's browser and examinie that. This would have to be done inside a timer just above the closing body tag in order to give the the website's main code a chance to render the ads before checking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.