Code implementation guide

Get and copy the ad code

To implement an ad unit or search box, you must first generate the AdSense ad code in your AdSense account. If you haven’t created an ad unit or search box yet, follow these steps.

After you've customised the appearance and settings of your ads or search box, the code that you generated is displayed in the "Ad code" box.

This is the ad code that you'll copy and paste into your site's HTML source code.  

If you've already created an ad unit but haven’t implemented the code yet, you can retrieve its code:

  1. Visit the My ads tab, find your ad unit in the list, and click Get code.
  2. Choose the code type that you want to use:
    • To use the asynchronous ad code, leave the code type set to "Asynchronous" in the Code type drop-down menu.
    • If you want to use the existing AdSense ad code, select "Synchronous" from the Code type drop-down menu.
    If you've chosen to create a responsive ad unit, you won't see the Code type drop-down menu in the “Ad code” box. Responsive ad units only use asynchronous ad code.
  3. Select the code by clicking anywhere in the Ad code box. You'll see the code highlighted in blue.
  4. Next, from your browser's Edit menu, choose Copy to copy the highlighted area.