My favorites | English | Sign in

Faster JavaScript with Closure Tools New!

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

ChannelService

Link to this version

Channels provide publishers with a way to track the performance, such as clickthrough rate, of their pages. By assigning a channel to any combination of pages, publishers can track a variety of metrics across their sites. For more information on channels, see the AdSense Help Center Channels FAQ.

In particular, ChannelService lets you create, list, and modify channels. To actually view reports, you must go to the AdSense website.

ChannelService provides two types of channels: URL channels and Custom channels, as specified in ChannelService_Data.type:

  • URL channels allow publishers to track the performance of their pages without modifying their ad code by entering a full or partial URL, They can enter a top-level domain name to track all of the pages on that domain, or they can enter a partial URL to track all of the pages below a certain directory. Entering a full URL will track the performance of that particular page.
  • Custom channels allow publishers to track performance based on their specified criteria. By pasting channel-specific ad code into their pages, publishers can track a variety of metrics across a range of URLs. Custom channels can be used to track the performance of different ad formats, for example, or to compare different page topics to one another.

ChannelService provides most operations in both single and batch form. For example, createChannel creates a single channel, and createChannels creates a batch of channels. Using a batch operation is more efficient than multiple calls to a single operation; therefore, you are encouraged to use the batch operations wherever possible.

Creating Channels

To create a channel, you must construct a ChannelService_Data object with parameters channel name, channel type ("Custom" or "Url"), status ("Active" or "Inactive"), and synServiceId. Then you can call either an individual or batch operation, createChannel or createChannels, to create the channels. These operations return a ChannelService_Data object with a unique id for each channel.

Updating Channels

You can activate or inactivate a channel or list of channels. You do this by setting the status in a ChannelService_Data and passing that into the updateChannel or updateChannels operation in ChannelService. Similarly, you can also change the name of a custom type channel this way.

Other Channel Operations

ChannelService also provides an operation getChannel to get ChannelService_Data given a channel ID, and its batch equivalent getChannels for a list of channel IDs. You can also call getSyndicationService to get SyndicationService_Data given a channel ID. In addition, you can delete a channel or list of channels.

Requests

createChannel

Create a new channel.

Parameters

channel ChannelService_Data
information about the new channel. ChannelService_Data.id is ignored in this data object.

Response

ChannelService_Data a new ChannelService_Data object with ChannelService_Data.id filled in.

Errors

201 if channel's syndication service ID is not valid
502 if a channel with the same name already exists
504 if adding another channel would go over the active channel limit
505 if channel's type is not valid
506 if channel's status is not valid
507 if channel's name is not valid

createChannels

Create new channels.

Parameters

channels ChannelService_Data[]
an array of information about the new channels. ChannelService_Data.id is ignored in these data objects.

Response

ChannelService_Data[] an array of new ChannelService_Data objects with ChannelService_Data.id filled in.

Errors

201 before creating any channels if any element of channels has a syndication service ID that is not valid
502 before creating any channels if any element of channels has the same name as a channel that already exists
503 before creating any channels if there are duplicate channels in channels
504 before creating any channels if adding the channels would go over the active channel limit
505 before creating any channels if any element of channels has a type that is not valid
506 before creating any channels if any element of channels has a status that is not valid
507 before creating any channels if any element of channels has a name that is not valid

deleteChannel

Delete a channel.

Parameters

channelId long
a channel ID for a channel that should be deleted

Response

(none)

Errors

501 if channelId doesn't represent an existing channel

deleteChannels

Delete multiple channels.

Parameters

channelIds long[]
an array of channel IDs for channels that should be deleted

Response

(none)

Errors

501 before deleting any channels if any element of channelIds doesn't represent an existing channel

getChannel

Get the channel data associated with a channel ID.

Parameters

channelId long
a channel ID.

Response

ChannelService_Data a ChannelService_Data object for the channel.

Errors

501 if channelId doesn't represent an existing channel

getChannelCode

Retrieve the channel code for channel. Channel codes are used by publishers to identify AdSense channels, whereas developers use ChannelService_Data.id to identify a channel within the API.

Parameters

channel ChannelService_Data
Specify only the synServiceId, type, status, and name fields. The other fields are not required to retrieve the channel code.

Response

string the channel code in the Channels table

getChannels

Get the data for an array of channel IDs.

Parameters

channelIds long[]
an array of channel IDs.

Response

ChannelService_Data[] an array of ChannelService_Data objects for the channels.

Errors

501 if any element of channelIds doesn't represent an existing channel

getSyndicationService

Returns the syndication service to which a specified channel belongs.

Parameters

channelId long
a channel ID for a channel

Response

SyndicationService_Data the syndication service that this Channel belongs to

Errors

501 if channelId doesn't represent an existing channel

updateChannel

Update information for a channel.

Parameters

channel ChannelService_Data
the ChannelService_Data that needs to be updated.

Response

(none)

Errors

201 if channel's syndication service ID is not valid
501 if channel doesn't represent an existing channel
503 if a channel with the same name already exists
504 if updating the channel would go over the active channel limit
505 if channel's type is not valid
506 if channel's status is not valid
507 if channel's name is not valid
508 if channel's type is modified
509 if channel's syndication service ID is modified
510 if channel is a URL channel and its name is modified

updateChannels

Update information for multiple channels.

Parameters

channels ChannelService_Data[]
an array of ChannelService_Data that need to be updated.

Response

(none)

Errors

201 before updating any channels if any element of channels has a syndication service ID that is not valid
501 if one of the channels in channels doesn't represent an existing channel
502 before updating any channels if any element of channels has the same name as a channel that already exists
503 before updating any channels if there are duplicate channels in channels
504 before updating any channels if updating the channels would go over the active channel limit
505 before updating any channels if any element of channels has a type that is not valid
506 before updating any channels if any element of channels has a status that is not valid
507 before updating any channels if any element of channels has a name that is not valid
508 before updating any channels if any element of channels has a type that is modified
509 before updating any channels if any element of channels has a syndication service ID that is modified
510 before updating any channels if any element of channels is a a URL channel and its name is modified