It's now possible to run ads via HTTPS channels with AdSense

Sep 17, 2013 08:46 GMT  ·  By

Google is making it possible for sites using encrypted HTTPS channels to run SSL-compliant AdSense ads. This is a major move towards a safer and more secure web, even if encryption isn't as trustworthy as it used to be, and sites which are already using the protocol will finally be able to monetize with ads from Google.

However, there are a few caveats which make the option only suitable for sites that already use HTTPS but not for those looking to upgrade from HTTP.

Because the ads themselves have to be SSL-compliant, HTTPS pages will have a smaller selection of ads bidding for the same space, resulting in lower ad revenues.

Still, for those who already have an HTTPS site, including ads could mean a revenue boost. Adding the new HTTPS-compliant AdSense code to your site isn't hard and the code isn't that much different.

In fact, all that's different is the switch from an http://-prefixed URL to a protocol-relative URL. This way, the protocol is picked depending on whether the visitor is using the plain HTTP or an HTTPS connection

The reason why the change was needed was a push by browser makers, including Google, to block mixed content from loading on HTTPS pages. For example, all modern browsers will issue a warning when you try to load unsecured ads via HTTP on a HTTPS page.

This is the old asynchronous code. The changes are similar for the synchronous code.

code
<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script>
And this is the new one:
code
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js">
</script>
The recent Firefox 23 will block mixed content scripts altogether, so no ads will be shown at all if they're served via HTTP. The move for stricter enforcement of SSL rules is a very welcomed one and should push websites to start putting more effort into complying with standards.