Code implementation guide

Get and copy the AdSense code

You get and copy the AdSense code from the Ads page in your AdSense account. How you generate the AdSense code will depend on whether you're using Auto ads or ad units. Note that for Auto ads you only need the AdSense code, but for ad units you need the AdSense code plus the ad unit code.

How to get and copy the code for Auto ads

To generate the AdSense code for Auto ads you first need to set up Auto ads for your entire site. If you've already done this, you can get the AdSense code by following these steps:

  1. Sign in to your AdSense account.
  2. Click Ads and then Overview.
  3. Click Get code.
  4. Click Copy code snippet.
After you've copied the AdSense code, the next step is to paste it between the <head> and </head> tags of your page. Learn where to place the AdSense code in your HTML.

How to get and copy the code for ad units

To generate the code for ad units, you first need to create an ad unit. If you've already done this, you can get the AdSense code and the ad unit code by following these steps:

  1. Sign in to your AdSense account.
  2. Click Ads and then Overview.
  3. Click By ad unit.
  4. In the "Existing ad units" table, find the ad unit whose code you want to get.
  5. Hover over the ad unit and click Get code Embed.
  6. Copy all of the ad unit code.
After you've copied the ad unit code, the next step is to paste it into the HTML of your page. Learn where to place ad unit code in your HTML.
Was this helpful?
How can we improve it?