Getting Ad Codes

Updated April 21, 2016

In the Adsense Help forum there are often requests on how to generate an ad code, and where to find it, so this page is for all those Newbies who are finding it difficult to follow the written information. These are the basic steps for generating ad codes for your website or blog from within your AdSense Account.

You won't get to choose what ad is displayed, or what company's ad is displayed, but you do get to decide if you want ads that contain images, or ads that only contain text, or a combination of both, and you'll select your ad block sizes, and the colours, or you can select a link unit instead of an ad unit.

Login to your AdSense account and look for the "MyAds" tab along the top menu. Once you've selected the "MyAds tab" in your AdSense account, a new page will open where you begin to make your choices for the design of your ad.

Screenshot of the my ads tab in an Adsense account.
Setting up your AdSense ad unit.
On the MyAds tab you begin by selecting the size and shape of your ad. In updating this tutorial for 2016, most publishers are likely to choose an option like "responsive-auto" for many of their ad choices. This is because with the increase in viewers using mobile devices like tablets and phones, responsive ads that are auto-sized respond automatically to the screen size (or viewport) of the device being use, making it easier for publishers to ensure their ads fit within the screen of the users (because, ads that are too big for a screen violate policy, and as publishers we don't know in advance what a visitor will be using to access our content).

The first thing you want to do is give the ad unit a name. The name is simply a way for you to tell which ad unit it is - what name you give it is your choice. You can use the name of your site, or the name of the place you want the ad for (ie: "mysite header", "mysite sidebar", etc.).

When you click the "recommended" tab you'll see a series of options to choose:

Showing the types of ad units you can choose in your AdSense account.
Choosing the type of ad you want.
Select the type of ad you want. If you want it to be responsive to screen sizes, choose responsive. If you want to give the ad your own custom sizing to fit your space exactly, choose custom (then you will need to give the pixel dimensions if you choose that), or if you don't want an ad unit and want link units, select "Link Ads".

How to give the dimensions you want for a custom sized AdSense ad Unit.
Setting the size for a custom-sized ad unit.
Choosing the responsive auto-sized ad unit or link ads for AdSense.
Responsive ad options.
Choosing a specific ad size for Adsense ad units.
Choosing specific ad sizes.
Each time you choose an option in the "recommended" box, you'll get another box to choose something From. If you choose Custom, the box you get lets you pick your pixel size (height and width) for the ad.  If you choose Responsive, you'll be asked to choose the automatic size or responsive link ads (code for responsive link units is new in 2016), if you choose any other option you'll get a box to choose the size of ad you want.

Simply select the option for whatever it is you want to display on your site.

After choosing the size, select the type of ads you want (ie: text only, image only, or both text/image).

Showing the types of options you can make when setting up AdSense ads.
Choosing options for the ad units.
Note that "text only" ad units are not the same as link units. 

Next you'll choose the colours of your ad ("text ad style"). Note that if you've selected "image only" ads, the colour choices aren't necessary. Image ads display the images that the advertiser has chosen and the ad design created by the advertiser, so changing ad colours for "image only" ads won't have any effect on the ad that displays on your page.

Custom channels is a way to help you track your ad placement's performance, so if you are interested in doing that you can set up a custom channel. While you can't check each individual ad that might appear in this ad slot, you can track the performance of this ad position. So if you are setting up a leaderboard ad to appear at the top position of your website, you'll be able to see statistics relating to this particular spot if you set up a channel for it.

The "Backup Ads" section lets you pick an option for those times when your ads don't display. This can happen sometimes if there are no ads available that match your content, or if your visitor is from a country where there are no applicable ads to display, or even when your site has a policy violation. Under whatever situation a normal adsense ad will not display, you can choose another option.

Backup ads must not be AdSense ads. If you use another ad provider use a page with that ad on it. Otherwise, you can choose a plain colour, or blank.

Once you've completed the choices on this page, click "continue" and you'll be given a dialogue box with your ad code in it - note that you can choose synchronous or asynchronous code (the default is "asynch".  Don't know what those choices mean? See the explanation in the AdSense Help Center.

The dialogue box that gives you the code for the ad unit to place in your site or blog.
The dialogue box containing the ad code.
The last step is to copy the ad code to place into your website or blog. This code must be copied from the box it's displayed in, and pasted into your site/blog using the html view of your site.

If you don't know how to find the html in your website or blog, then you'll need to. On some blogs you can use gadgets or widgets for placing the code in - this will need to be an html/javascript widget/gadget, or for some blog types, a simple text widget.

On some website builders there are specified AdSense or link gadget boxes you can use. If you don't know how to do this, you'll need to ask for help in a web development forum or at your webhost if the webhost has provided the website builder.

Make sure you copy everything in the box, from start to finish, and that the code pastes into your website or your notepad in exactly the same way as it displays in the code box on your page.

If you save the code into a widget or gadget, all you need to do is save the widget/gadget.

If you've inserted the code directly into the html of a web page, you will need to save your edits, and publish (or re-publish) your page.