My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Documentation for the requested version is not available.Documentation for the requested diff is not available.

AdSenseForContentService

Link to this version

AdSenseForContentService (AFC) allows a developer to generate ad code snippets to include in a publisher's web pages to start serving and displaying contextual advertising. When an end-user clicks through an ad, Google credits a payment.

AFC also allows a user to associate Channels with the service, create and save AdStyle objects and get ad types with the service.

Generating Ad Code Snippet

To generate an ad code snippet, you call the generateAdCode operation, passing in eight parameters, starting with:

Six parameters define ad layout, type, style, substitution and placement:

  • layout chooses the ad's dimensions from a number of defined layouts
  • adUnitType chooses from image-only, text-only, image-and-text, 4-link unit or 5-link unit
  • adStyle chooses the background color of the ad
  • cornerStyles chooses the corner style for the ad unit
  • alternate specifies alternate content to replace public service announcements (PSA): it can be either a URL for alternate content, or a six-digit hexidecimal color code (starting with '#') rendered as a solid block of color. Substituting a PSA with a solid color that matches the background of your web page can, for all practical purposes, make the ad disappear
  • isFramedPage is a boolean indicating if the ad code snippet will be placed within a frame in a page

One parameter defines the channel:

  • channelName is the channel to be used to track statistics for this page

This generateAdCode operation returns the ad code snippet as a string that you can paste into web pages to begin serving ads.

Viewing and Updating Ads and Channels

AdSenseForContentService lets you do the following and more:

  • Get and modify ad styles (color)
  • Get ad layouts (size)
  • Get ad unit type (text, image or both)
  • Get channels (get all, get active, get inactive)

Rather than modify existing ad layouts or ad unit types, you just regenerate the code. See ChannelService for updating channels.

Requests

deleteAdStyle

Delete a named ad style from this service.

Parameters

synServiceId string
the ID of this service.
name string
the name of an ad style

Response

(none)

Errors

201 if synServiceId is not valid
409 if there is no style with the specified name

deleteAdStyles

Delete a collection of named ad styles from this service.

Parameters

synServiceId string
the ID of this service.
names string[]
the names of some ad styles

Response

(none)

Errors

201 before deleting any styles if synServiceId is not valid
409 before deleting any styles if any of the names in names do not correspond to an existing style

generateAdCode

Generates the ad code snippet that can be dropped into an HTML page for the page to start receiving Google Ads.

Parameters

synServiceId string
the syndication service ID
adStyle AdStyle
the ad style
adUnitType AdUnitType
the type of ad unit or link unit. An empty string causes the default ad unit type to be used. (The default type is TextOnly, which can be changed at the AdWords website.) See Ad Formats table.

Values are:

  • TextOnly - This option corresponds to the display of text ads only
  • ImageOnly - This option corresponds to the display of image ads only
  • TextAndImage - This option corresponds to the display of both text and image ads
  • FourLinkUnit - This option corresponds to the display of a link unit with 4 links per unit.
  • FiveLinkUnit - This option corresponds to the display of a link unit with 5 links per unit.

layout AdLayout
the layout of the ad(s). Note that the layout must be an acceptable one based upon the ad type. Values are width x height in pixels. See Ad Formats table.

Values are:

  • 728x90
  • 468x60
  • 300x250
  • 160x600
  • 120x600
  • 336x280
  • 250x250
  • 234x60
  • 180x150
  • 200x200
  • 125x125
  • 120x240
  • 728x15
  • 468x15
  • 200x90
  • 180x90
  • 160x90
  • 120x90

alternate string
the alternate content used to replace public service ads. This is usually nil. If this begins with a # it is interpreted as a six-digit hexidecimal color code, typically the background color of the page or frame on which this ad unit will appear. Otherwise this is interpreted as a URL that should point to a replacement ad.
isFramedPage boolean
true if the ad code snippet will be placed within a frame in a page.
channelName string
the channel that should be used to track statistics for this page. The channel type should be custom. If no Channel is to be specified, this argument should be passed as nil.

Response

string html elements that can be dropped into an HTML page for the page to start receiving Google Ads.

Errors

201 if synServiceId is not valid
314 if synServiceId doesn't correspond to a Content Ads service
401 if adStyle's name is not valid
403 if any of adStyle's colors is not valid
404 if adUnitType is not valid
405 if adLayout is not valid
406 if the adUnitType and adLayout are incompatible
410 if alternate is not valid
501 if channelName is not valid or if channel type is not custom

generateAdCode +v3

Generates the ad code snippet that can be dropped into an HTML page for the page to start receiving Google Ads.

Parameters

synServiceId string
the syndication service ID
adStyle AdStyle
the ad style
adUnitType AdUnitType
the type of ad unit or link unit. An empty string causes the default ad unit type to be used. (The default type is TextOnly, which can be changed at the AdWords website.) See Ad Formats table.

Values are:

  • TextOnly - This option corresponds to the display of text ads only
  • ImageOnly - This option corresponds to the display of image ads only
  • TextAndImage - This option corresponds to the display of both text and image ads
  • FourLinkUnit - This option corresponds to the display of a link unit with 4 links per unit.
  • FiveLinkUnit - This option corresponds to the display of a link unit with 5 links per unit.

layout AdLayout
the layout of the ad(s). Note that the layout must be an acceptable one based upon the ad type. Values are width x height in pixels. See Ad Formats table.

Values are:

  • 728x90
  • 468x60
  • 300x250
  • 160x600
  • 120x600
  • 336x280
  • 250x250
  • 234x60
  • 180x150
  • 200x200
  • 125x125
  • 120x240
  • 728x15
  • 468x15
  • 200x90
  • 180x90
  • 160x90
  • 120x90

alternate string
the alternate content used to replace public service ads. This is usually nil. If this begins with a # it is interpreted as a six-digit hexidecimal color code, typically the background color of the page or frame on which this ad unit will appear. Otherwise this is interpreted as a URL that should point to a replacement ad.
isFramedPage boolean
true if the ad code snippet will be placed within a frame in a page.
channelName string
the channel that should be used to track statistics for this page. The channel type should be custom. If no Channel is to be specified, this argument should be passed as nil.
cornerStyles CornerStyles
the corner style that should be used for the requested ad unit.

Values are:

  • DEFAULT
  • SQUARE_CORNERS
  • SLIGHTLY_ROUNDED_CORNERS
  • VERY_ROUNDED_CORNERS

hostChannelNames string[]
List of AFC host channels that should be used to track statistics for this ad code. Up to five channels are allowed. If you are not using host channels, set this field to nil. For more information on host channels, see the Host Channel FAQ.

Response

string an HTML snippet that can be dropped into an HTML page for the page to start receiving Google Ads.

Errors

201 if synServiceId is not valid
314 if synServiceId doesn't correspond to a Content Ads service
401 if adStyle's name is not valid
403 if any of adStyle's colors is not valid
404 if adUnitType is not valid
405 if adLayout is not valid
406 if the adUnitType and adLayout are incompatible
410 if alternate is not valid
412 if cornerStyles is not valid
501 if channelName or the host channel name in hostChannelNames is not valid or if channel type is not custom
809 if the number of host channel names in hostChannelNames exceeds the limitation

getActiveChannels

Returns the active Channels associated with this syndication service for the publisher.

Parameters

synServiceId string
the ID of this service.
type ChannelService_Type
the ChannelService type of the Channels

Values are:

  • Url - Channel is a URL channel
  • Custom - Channel is a custom channel

Response

ChannelService_Data[] an array of ChannelService_Data corresponding to the active Channels associated with this syndication service for the publisher.

Errors

201 if synServiceId is not valid
505 if type is not valid

getAdLayouts

Get all ad layouts compatible with a particular ad unit type. See Ad Formats table. Passing "" as adUnitType will get all ad layouts of the default ad unit type. (The default type is TextOnly, which can be changed at the AdWords website.)

Parameters

adUnitType AdUnitType
the type of ad unit desired, or "" to return all layouts of the default ad unit type See Ad Formats table.

Values are:

  • TextOnly - This option corresponds to the display of text ads only
  • ImageOnly - This option corresponds to the display of image ads only
  • TextAndImage - This option corresponds to the display of both text and image ads
  • FourLinkUnit - This option corresponds to the display of a link unit with 4 links per unit.
  • FiveLinkUnit - This option corresponds to the display of a link unit with 5 links per unit.

Response

AdLayout[] all ad layouts that can be used with adUnitType in a call to generateAdCode. Values are width x height in pixels. See Ad Formats table.

Values are:

  • 728x90
  • 468x60
  • 300x250
  • 160x600
  • 120x600
  • 336x280
  • 250x250
  • 234x60
  • 180x150
  • 200x200
  • 125x125
  • 120x240
  • 728x15
  • 468x15
  • 200x90
  • 180x90
  • 160x90
  • 120x90

Errors

404 if adUnitType is not valid

getAdStyles

Returns the ad styles created by the publisher.

Parameters

synServiceId string
the ID of this service.

Response

AdStyle[] an array of AdStyles created by the publisher.

Errors

201 if synServiceId is not valid

getAdUnitTypes

Get all ad unit types compatible with a particular ad layout.

Parameters

adLayout AdLayout
the type of ad layout desired. Values are width x height in pixels. See Ad Formats table.

Values are:

  • 728x90
  • 468x60
  • 300x250
  • 160x600
  • 120x600
  • 336x280
  • 250x250
  • 234x60
  • 180x150
  • 200x200
  • 125x125
  • 120x240
  • 728x15
  • 468x15
  • 200x90
  • 180x90
  • 160x90
  • 120x90

Response

AdUnitType[] all ad unit types that can be used with adLayout in a call to generateAdCode.

Values are:

  • TextOnly - This option corresponds to the display of text ads only
  • ImageOnly - This option corresponds to the display of image ads only
  • TextAndImage - This option corresponds to the display of both text and image ads
  • FourLinkUnit - This option corresponds to the display of a link unit with 4 links per unit.
  • FiveLinkUnit - This option corresponds to the display of a link unit with 5 links per unit.

Errors

405 if adLayout is not valid

getAllAdLayouts

Get all ad layouts supported by Google.

Parameters

dummy int
a dummy argument

Response

AdLayout[] all ad layouts that can be used in a call to generateAdCode. Values are width x height in pixels. See Ad Formats table.

Values are:

  • 728x90
  • 468x60
  • 300x250
  • 160x600
  • 120x600
  • 336x280
  • 250x250
  • 234x60
  • 180x150
  • 200x200
  • 125x125
  • 120x240
  • 728x15
  • 468x15
  • 200x90
  • 180x90
  • 160x90
  • 120x90

getAllAdUnitTypes

Get all ad unit types supported by Google.

Parameters

dummy int
a dummy argument.

Response

AdUnitType[] all ad unit types that can be used in a call to generateAdCode.

Values are:

  • TextOnly - This option corresponds to the display of text ads only
  • ImageOnly - This option corresponds to the display of image ads only
  • TextAndImage - This option corresponds to the display of both text and image ads
  • FourLinkUnit - This option corresponds to the display of a link unit with 4 links per unit.
  • FiveLinkUnit - This option corresponds to the display of a link unit with 5 links per unit.

getBuiltinAdStyles

Returns the built-in ad styles created by Google.

Parameters

dummy int
a dummy argument

Response

AdStyle[] an array of ad styles created by Google.

getChannels

Returns the Channels associated with this syndication service for the publisher.

Parameters

synServiceId string
the ID of this service.
type ChannelService_Type
the ChannelService type of the Channels

Values are:

  • Url - Channel is a URL channel
  • Custom - Channel is a custom channel

Response

ChannelService_Data[] an array of ChannelService_Data corresponding to the Channels associated with this service for the publisher.

Errors

201 if synServiceId is not valid
505 if type is not valid

getInactiveChannels

Returns the inactive Channels associated with this syndication service for the publisher.

Parameters

synServiceId string
the ID of this service.
type ChannelService_Type
the ChannelService type of the Channels

Values are:

  • Url - Channel is a URL channel
  • Custom - Channel is a custom channel

Response

ChannelService_Data[] an array of ChannelService_Data corresponding to the inactive Channels associated with this syndication service for the publisher.

Errors

201 if synServiceId is not valid
505 if type is not valid

saveAdStyle

Saves a named ad style. If an ad style with this name is already saved, this will overwrite the style's contents.

Parameters

synServiceId string
the ID of this service.
adStyle AdStyle
a named ad style

Response

(none)

Errors

201 if synServiceId is not valid
401 if adStyle's name is not valid
402 if adStyle's name is empty
403 if any of adStyle's color is not valid
408 if saving the ad style would go over the saved ad style limit

saveAdStyles

Adds a collection of named ad styles to this service.

Parameters

synServiceId string
the ID of this service.
adStyles AdStyle[]
an array of named ad styles

Response

(none)

Errors

201 before saving any styles if any element of adStyles has a synServiceId that is not valid
401 before saving any styles if any element of adStyles has a name that is not valid
402 before saving any styles if any element of adStyles has a name that is empty
403 before saving any styles if any element of adStyles has a color that is not valid
407 before saving any styles if there are styles with the same name in adStyles
408 before saving any styles if saving the ad styles would go over the saved ad style limit