Search
Clear search
Close search
Google apps
Main menu

Get and copy the ad code

To generate your AdSense ad code you first need to create an ad unit. You do this on the My ads tab in your AdSense account. There are a few different types of ad unit that you can choose from. Once you've decided which type of ad unit you want to create, follow the steps below to get and copy your ad code.

Ad unit: A set of Google ads displayed as a result of one piece of AdSense ad code.

Types of ad unit

AdSense offers several different types of ad unit. If a standard ad unit doesn't meet the requirements of your site, consider using one of our more specialized ad units:

Type Description
Ad unit
Custom-sized ad unit
  • Non-standard size ad unit
  • Allows you to specify the width and height of the ad that you want to appear on your page. Learn more about custom-sized ad units.
Responsive ad unit
  • Adaptable ad unit
  • Allows you to support a wide range of devices (i.e., computers, phones, tablets, etc.) by automatically adapting its size to fit your page layout. Learn more about responsive ad units.
Matched content unit
  • Block of content recommendations
  • Generates contextually relevant and personalized article recommendations from the pages on your website. Learn more about the Matched content feature.

How to get and copy your ad code

Select an option below and follow the instructions to get and copy your ad code:

If you haven't yet created an ad unit
  1. Sign in to your AdSense account.
  2. Visit the My ads tab.
  3. In the sidebar, select your product. For example, if you want to display ads on your website, select "Content".
  4. Click +New ad unit.
  5. Give your ad unit a name. It’s a good idea to use a unique, descriptive name that will help you find this ad unit later.
  6. In the "Ad size" section, choose the size of the ads that you’d like to show.
    In general, wider ad units perform better. We encourage you to choose one of our recommended ad sizes, which have shown to perform well across a variety of sites. Ad sizes that perform well on mobile are shown with a mobile icon mobile icon.
  7. Select which type of ads you’d like to show on your pages from the Ad type drop-down. We highly recommend that you display both text and display ads. By displaying more ad types, you can earn more revenue.
    Note that if you're eligible for Matched content, you'll see the option to create a Matched content unit in the Ad type drop-down.
  8. (Optional) Apply an ad style for your text ads. Learn more about choosing the right ad style.
  9. (Optional) Set up a custom channel to track your ad unit. Learn more about custom channels.
  10. In the "Backup ads" section, leave the drop-down set to "Show blank space" (the default) unless you’d like to show something else if Google has no targeted ads available. Learn more about backup ads.
  11. Click Save and get code.
  12. In the "Ad code" box that opens:
    1. Leave the code type set to "Asynchronous" (the default), unless you want to use synchronous ad code. Learn more about asynchronous ad code.
      If you've chosen to create a responsive ad unit, you won't see the Code type drop-down in the "Ad code" box. Responsive ad units only use asynchronous ad code.
    2. Select the ad code by clicking it. You'll see the ad code highlighted in blue.Example of the "Ad code" box
    3. Copy all of the ad code, e.g., press Ctrl+C (Windows) or ⌘+C (Mac).
If you've already created an ad unit
  1. Sign in to your AdSense account.
  2. Visit the My ads tab.
  3. In the sidebar, make sure Content is selected.
  4. Find your ad unit in the list of ad units, and click Get code.
  5. In the "Ad code" box that opens:
    1. Leave the code type set to "Asynchronous" (the default), unless you want to use synchronous ad code. Learn more about asynchronous ad code.
      If you've chosen to create a responsive ad unit, you won't see the Code type drop-down in the "Ad code" box. Responsive ad units only use asynchronous ad code.
    2. Select the ad code by clicking it. You'll see the ad code highlighted in blue.Example of the "Ad code" box
    3. Copy all of the ad code, e.g., press Ctrl+C (Windows) or ⌘+C (Mac).
Was this article helpful?
How can we improve it?
Sign in to AdSense

Sign in to AdSense to see help for your account

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