Ad code implementation
About the asynchronous ad code
The asynchronous ad code is a fully asynchronous version of the AdSense ad code that offers improved web latency and a better user experience for your site’s visitors. The advantage of the asynchronous code is that it's guaranteed never to get in the way of other parts of your web page loading. This means that users will be able to load the content of your pages, even if they’re having trouble loading the ads. In particular, mobile users will enjoy less latency when loading web pages.
The key differences between asynchronous and synchronous ad code are:
- Speed: Asynchronous ad code offers improved web latency, especially on mobile.
- Improved user experience: Using asynchronous ad code ensures that your users see your content, even if they’re having trouble loading your ads.
For more information, see this Inside AdSense blog post: Faster, more robust web with AdSense.
Implementing the asynchronous ad code
When you generate your AdSense ad code, you have the option to choose between the asynchronous ad code and the existing AdSense ad code. To use the asynchronous code, leave the code type set to "Asynchronous" in the Code type drop-down in the “Ad code” box. Once you’ve generated your asynchronous code, copy and paste the code into your page’s HTML source code, just as you would with the current ad code.
Syntax for the asynchronous code
The asynchronous ad code has a different syntax to the current AdSense ad code. Here's a side-by-side comparison of the two types of ad code:
|Asynchronous ad code||Synchronous ad code|
For more information about why ads may not display on your website after correctly adding the asynchronous ad code, see content ads are not showing up.
Frequently asked questions