Basics of Google AdSense Ad Code

On This Page,You can easily know about Basics of Google AdSense Ad Code.

An ad unit is one or more Google ads displayed as a result of one piece of the AdSense ad code. You can create, customize and manage ad units on the Ads page in your AdSense account. Ad units give you control over where ads appear, and our native ad units offer lots of flexibility in terms of customization.

What is AdSense Ad Unit?

AdSesne ad unit is a piece of script to be embedded in your webpage in order to display ads from Google. The script will be triggered when the page is loaded which will send an ad request to the nearest Google server located. Server will return appropriate ad based on ad auction and the script will then display the ads in the webpage. Each and every ad unit in a webpage sends an ad request which is recorded in your AdSense account as ad request count.

Below is the example of how an AdSense ad script code looks like:

Google Adsense Ad code

AdSense ad code is to be generated from your AdSense account and is to be embedded in your webpage in order to display ads on your page. Learn more creating Ad units.

Various Terms Used in AdSense Ad 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:

Sign in to your AdSense account.
Click Ads and then Overview.
Click Get code.
Click Copy code snippet.

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:

Sign in to your AdSense account.
Click Ads and then Overview.
Click By ad unit.
In the “Existing ad units” table, find the ad unit whose code you want to get.
Hover over the ad unit and click Get code Embed.
Copy all of the ad unit code.

Example HTML page before the ad unit code has been added

pgm 1

Example HTML page with the ad unit code added in the body

pgm 2

Positioning the ads on your site with HTML

pgm 3

Following is the explanation of the terms used in an AdSense ad script code.

Script – AdSense ad code is a server side JavaScript code embedded in any webpage. This script calls the server through API in the background and retrieve the relevant ad to be displayed on the page.
Ad Client – This is the publisher’s AdSense id, which can be used anonymously in any ad codes. In order to avoid misuse of the publisher code, Google introduced site authorization concept where publishers can authorize the sites to display their AdSense ads. You can add authorized sites to display your ads in your AdSense account under “Access and authorization” section available in “Account settings”.

site

Ad Slot – This is a slot number assigned automatically by Google in order to track any particular ad.
Width and Height – Determines the size of the ad to be displayed in a webpage.
pagead2.googlesyndication.com script – This collects the information regarding the user behavior to display appropriate ads to be served for that user.

Leave a Reply