Ad code implementation

AdSense ad code support for SSL

We’ve updated the AdSense ad code so that it now supports secure ad serving through Secure Sockets Layer (SSL) on Hypertext Transfer Protocol Secure (HTTPS) web pages. This means that publishers with secure sites, i.e., sites that are served over the HTTPS protocol, can now use AdSense ad code to serve SSL-compliant ads. Examples of secure websites include many financial services sites, e-commerce sites, and social networking sites.

Some important things to know about the SSL-compatible ad code:

  • HTTPS-enabled sites require that all content on the page, including the ads, be SSL-compliant. As such, AdSense will remove all non-SSL compliant ads from competing in the auction on these pages. If you do decide to convert your HTTP site to HTTPS, please be aware that because we remove non-SSL compliant ads from the auction, thereby reducing auction pressure, ads on your HTTPS pages might earn less than those on your HTTP pages.

  • The SSL-compatible code also works on HTTP sites and doesn’t change how ads are served on these sites.
Older versions of the AdSense ad code don’t work with secure content. If you try to run HTTP ads on an HTTPS site, on most older browsers your visitors will get a mixed content warning, while on some modern browsers your visitors might not see any ads at all. If you want to place ads on secure pages, you’ll need to use the new SSL-compatible ad code.

How to use the SSL-compatible ad code

To use the new ad code on your HTTPS-enabled pages, use either of the options outlined here:

Option 1: Create new ad code

Generate your ad code, and then copy and paste the ad code into the HTML source code of your page where you'd like the ad to appear.

Option 2: Modify your existing ad code

To do this you'll need to make the following code change:

  • Synchronous ad code
    <script src="//"></script>

  • Asynchronous ad code
    <script async src="//"></script>
    <ins class="adsbygoogle"
      (adsbygoogle=window.adsbygoogle || []).push({});
In the examples above, “http” has been removed from both script sources. The source URLs now begin with two forward slashes, like this:
  • Synchronous ad code: "//"
  • Asynchronous ad code: "//"
Was this article helpful?
Sign in to AdSense

Sign in to AdSense to see help for your account

Don't have an AdSense account? Sign Up for AdSense!