AdsApp.​TopicBuilder

  • The TopicBuilder facilitates the creation and management of topics for targeting in Google Ads campaigns.

  • It allows for specifying the topic ID, setting maximum CPC or CPM bids, and building or excluding topics.

  • The withTopicId method is mandatory and uses a topic ID to identify the desired category, while withCpc and withCpm are optional for setting bids.

  • The build method creates a TopicOperation to add the topic, while the exclude method creates an ExcludedTopicOperation to exclude it.

Builder for Topic objects.

Example usage:

var topicBuilder = adGroup.display().newTopicBuilder();
var topic = topicBuilder
  .withTopicId(3)                 // required
  .withCpc(0.50)                  // optional
  .build()                        // create the topic

Methods:

MemberTypeDescription
build() AdsApp.TopicOperation Builds the topic.
exclude() AdsApp.ExcludedTopicOperation Builds the excluded topic.
withCpc(cpc) AdsApp.TopicBuilder Sets the max CPC bid of the new topic to the specified value.
withCpm(cpm) AdsApp.TopicBuilder Sets the CPM bid of the new topic to the specified value.
withTopicId(topicId) AdsApp.TopicBuilder Sets the topic ID of the topic.

build()

Builds the topic. Returns a TopicOperation that corresponds to the creation of the Topic.

Return values:

TypeDescription
AdsApp.TopicOperation The TopicOperation.

exclude()

Builds the excluded topic. Returns an ExcludedTopicOperation that corresponds to the creation of the ExcludedTopic.

Return values:

TypeDescription
AdsApp.ExcludedTopicOperation The ExcludedTopicOperation.

withCpc(cpc)

Sets the max CPC bid of the new topic to the specified value.

Arguments:

NameTypeDescription
cpc double The max CPC bid of the topic.

Return values:

TypeDescription
AdsApp.TopicBuilder The topic builder with the specified max CPC.

withCpm(cpm)

Sets the CPM bid of the new topic to the specified value.

See Cost-per-thousand impressions (CPM) for more information.

Arguments:

NameTypeDescription
cpm double The CPM bid of the topic.

Return values:

TypeDescription
AdsApp.TopicBuilder The topic builder with the specified CPM.

withTopicId(topicId)

Sets the topic ID of the topic. This field is required. The topic ID identifies the topic category. A list of valid topic IDs is available on our Verticals page.

Arguments:

NameTypeDescription
topicId String The topic ID of the topic.

Return values:

TypeDescription
AdsApp.TopicBuilder A TopicBuilder with the specified topic ID.