Query

ParameterDescription
query Required
This is the search query entered by the user. The value of the query parameter should be unencoded.

Examples:

'query' : 'flowers'
'query' : 'black & decker'
'query' : myQuery // myQuery is a variable containing the search query

Pub ID

ParameterDescription
pubId Required
This is your AdSense publisher ID and must be in the format pub-xxxxxxxxxxxxxxxx.

Example:

'pubId' : 'pub-xxxxxxxxxxxxxxxx'

Number of Ads

ParameterDescription
number Optional
The number of ads which should appear in this unit. The default value is 2.

Example:

'number' : 4

Page Number

ParameterDescription
adPage Required when the user navigates to the next results page or previous results page.

The adPage parameter specifies the results page ads are being displayed on. This parameter is used when users navigate past the first page of search results. For example, if five ads are requested, and the adPage parameter is set to 2, the returned ads will be the second page of five ads.

Ad Language

ParameterDescription
hl Optional
This parameter identifies the language that the requested ads or related searches should target. The default value is en.

Google supports all AdWords API language codes.

Note: Advertisers specify the languages that their ads target. If you include this parameter in your request, Google only returns ads that are targeted for that language or targeted for all languages but it does not guarantee that the ad text will be in the specified language.

Typically, you should set the hl parameter to the primary language of the page from which this parameter is sent.

Examples:

'hl' : 'es'

Adsafe Level

ParameterDescription
adsafe Optional
Specifies the filtering rules that Google should apply to ads matching the search query. The following are the valid settings for adsafe and the effect each value has on returned ads:
  • 'high' Returns family-safe ads. Does not return non-family-safe or adult sexual content ads.
  • 'medium' Returns family-safe and non-family-safe ads. Does not return adult sexual content ads.
  • 'low' Returns all types of ads.

By default adsafe is set to high.

Example:

'adsafe': 'medium'

Channel ID

ParameterDescription
channel Optional
You may include an AdSense for Search channel for tracking the performance of different pages. Use the unique channel ID generated from your AdSense account. Learn more about channels here.

Multiple channels should be separated by the '+' symbol.

Examples:

'channel' :  '123456789'  
'channel' :  '123456789+987654321'  

Testing Mode

ParameterDescription
adtest Optional
The adtest parameter is used to indicate that a request for ads is a test. When the adtest parameter has a value of on, Google treats the request as a test and does not count the ad impressions or track the clickthrough results.

When the adtest parameter has a value of on, you do not generate any revenue.

Use this parameter when testing, but do not use it in production systems or you will not be paid for ads that you display.

The default adtest value is off.

Example:

'adtest' : 'on'

Location

ParameterDescription
location Optional

Provides a way for the ad to display location information such as the address. See example below:


By default, location extensions are enabled . If you wish to disable them use this line of code:

'location' :  false 

Domain Link Above Description

ParameterDescription
domainLinkAboveDescription Optional

Specifies that the visible URL line will be displayed above the description line for each ad. This only applies to the 3 line ad format.

Displaying the visible URL above the description is the default behavior. If you wish to see the URL below the description use this line of code:

'domainLinkAboveDescription': false

Seller Ratings

ParameterDescription
sellerRatings Optional

Seller rating extensions provide user-submitted ratings information about sellers next to their ads. These reviews reflect users' buying experience with these businesses, rather than their experience with particular products.

This feature is offered as a service to our users to let them know about advertisers who are rated well by their customers while viewing relevant ads. This helps users make more informed web browsing and purchase decisions while helping advertisers increase their potential for earning more qualified leads. See example below:


By default, seller rating extensions are enabled . If you wish to disable them use this line of code:

'sellerRatings' :  false 

Container ID

ParameterDescription
container Required
The id of the empty ad container <div> where the ad should appear.

Example:

'container' : 'afscontainer1'

Width

ParameterDescription
width Required
Specifies the width of the ad or related search unit in pixels.

Example:

'width' : '700px'
'width' : 700

Underline Title

ParameterDescription
noTitleUnderline Optional
Specifies whether or not the ad title will be underlined.

Example:

'noTitleUnderline': true

Bold Title

ParameterDescription
titleBold Optional
Allows the entire ad title line to be bold. By default, titleBold is set to false.

Example:

'titleBold' : true

Spacing Between Ads

ParameterDescription
verticalSpacing Optional
Specifies the amount of vertical spacing between ads in pixels. Note that 4px of padding are automatically added to the top and bottom of each ad for a total of 8 pixels. The default value for verticalSpacing is 4, the min is 2, and the max is 12. So the minimum padding between ads is 4px(top) + 4px(bottom) + 2px (minimum vertical space) = 10px. Total vertical spacing between ads= 4px(top) + 4px(bottom) + verticalSpacing.

Example:

'verticalSpacing' : 5

Spacing Between Attribution and Ads

ParameterDescription
attributionSpacingBelow Optional

Specifies the amount of vertical spacing between the attribution and the ads in pixels. Note that 4px of padding are automatically added and this value specifies the number of additional pixels. The default value of attributionSpacingBelow is 0. The min value is 0 and the max value is 40.

Example:

'attributionSpacingBelow' : 2

Font family

ParameterDescription
fontFamily Optional
Specifies the font family of the entire ad unit. On desktop, the default font is Arial; on mobile, the default fonts are Roboto (Android) and Helvetica Neue (iOS) This parameter supports a comma-separated list of fonts. CSA will use the first font from the list that is supported by the user's browser.

Supported font families are:
  • 'verdana'
  • 'arial'
  • 'tahoma'
  • 'times new roman'
  • 'georgia'
  • 'trebuchet ms'
  • 'roboto'
  • 'helvetica neue'
  • 'meiryo'
  • 'ms gothic'

Examples:

'fontFamily' : 'georgia'
'fontFamily' : 'verdana, arial, times new roman'

Title font size

ParameterDescription
fontSizeTitle Optional
Specifies the size (in pixels) of the ad title. Valid values are from 8-16px. Default size is 12px. Note that the maximum difference allowed between font sizes within an ad unit (i.e. title, description, attribution, visible URL, ad extensions) is 6px.

Example:

'fontSizeTitle' : 12

Description font size

ParameterDescription
fontSizeDescription Optional
Specifies the size (in pixels) of the ad description text. Valid values are from 8-16px. Default size is 12px. Note that the maximum difference allowed between font sizes within an ad unit (i.e. title, description, attribution, visible URL, ad extensions) is 6px.

Example:

'fontSizeDescription' : 10

Attribution font size

ParameterDescription
fontSizeAttribution Optional
Specifies the size (in pixels) of the attribution. Valid values are from 8-16px. The default size is 13px. Note that the maximum difference allowed between font sizes within an ad unit (i.e. title, description, attribution, visible URL, ad extensions) is 6px.

Example:

'fontSizeAttribution' : 14

Description color

ParameterDescription
colorText Optional
Specifies the color of the ad description text.

Example:

'colorText' : '#000000'

Attribution color

ParameterDescription
colorAttribution Optional
Specifies the color of the attribution. The default color of the attribution is #666666.

Example:

'colorAttribution' : '#996699'

Background color

ParameterDescription
colorBackground Optional
Specifies the background color of the ad.

Example:

'colorBackground' : '#FFFFFF'

Border color for each ad

ParameterDescription
colorAdBorder Optional
Places a border in the specified color around an individual ad and creates a "box" look around each ad.

Example:

'colorAdBorder' : '#ADDFFF'

Border color for ad unit

ParameterDescription
colorBorder Optional
Specifies a 1px border color for the ad unit. If none is provided the ad unit will have no border.

Example:

'colorBorder' : '#0099FF'

Ad separator color

ParameterDescription
colorAdSeparator Optional
Places a 1px border between the ads in an ad block. The default is off with no border between ads.

Example:

'colorAdSeparator' : '#000000'

Detailed Attribution

ParameterDescription
detailedAttribution Optional

Extends the attribution to include the user query. See example below:


By default, detailed attribution is enabled . If you wish to disable this use the following line of code:

'detailedAttribution' :  false 

Type of ad

Location of the ad on the page: above the fold (ATF) or below the fold (BTF). If the ad is ATF, use the maxTop parameter instead of the number parameter.

Seller First

ParameterDescription
adLayout Optional

Ad Layout is a feature that enables a new UI layout.

Possible UI layouts include:

  • 'threeline'
  • 'sellerFirst'

Seller First Layout:

By default, adLayout is disabled. If you wish to enable it, use this line of code:

'adLayout' : 'sellerFirst'

To use this code you must have an AdSense account with active permission to use AdSense Custom Search Ads.

Note: By leaving "default" for some settings, you will automatically receive future optimizations to maximize performance.
Page Options
Required
Pub ID
Query
Number of ad units
Page Number
Configuration Settings
Ad Language
Adsafe Level
Channel ID
Testing Mode
Ad Extensions
Location extension
Click To Call
Seller Ratings
Site Links
Ad Unit 1 Options
Required
Container ID
Width (px)
Configuration Settings
Type of ad
Number of ads
Fonts
Font family
Title font size
Description font size
Domain link font size
Colors
Title color
Description color
Link color
Background color
Border color for each ad
Border color for ad unit
Ad Extensions
Detailed Attribution
Ad Unit 1 Preview
Get the Code

Important:Please read the Terms and Conditions before using this code.

Place this code in the <head> tag on your page.
          
Place this code in the <body> tag on your page.