AdWordsApp.​AdBuilder

Builder for an ad under construction.

Typical usage:

 var adOperation = adGroup.newTextAdBuilder()
    .withHeadline("headline of ad")
    .withDescription1("first line of ad description")
    .withDescription2("second line of ad description")
    .withDisplayUrl("www.example.com")
    .withFinalUrl("http://www.example.com")
    .build();
 var ad = adOperation.getResult();

Note that it is only necessary to call AdOperation.getResult() if you need to access the actual ad for further processing (for instance, one can attach a label to the newly created ad), otherwise, calling AdBuilder.build() on the AdBuilder is sufficient to ensure that the ad is created.

Methods:

MemberTypeDescription
build AdWordsApp.AdOperation Creates an Ad.
withCustomParameters AdWordsApp.AdBuilder Sets the custom parameters of the new ad to the specified value.
withDescription1 AdWordsApp.AdBuilder Sets the first line of the new ad's description to the specified value.
withDescription2 AdWordsApp.AdBuilder Sets the second line of the new ad's description to the specified value.
withDisplayUrl AdWordsApp.AdBuilder Sets the display URL of the new ad to the specified value.
withFinalUrl AdWordsApp.AdBuilder Sets the final URL of the new ad to the specified value.
withHeadline AdWordsApp.AdBuilder Sets the headline of the new ad to the specified value.
withMobileFinalUrl AdWordsApp.AdBuilder Sets the mobile final URL of the new ad to the specified value.
withMobilePreferred AdWordsApp.AdBuilder Sets the new ad's device preference to mobile or clears it.
withTrackingTemplate AdWordsApp.AdBuilder Sets the tracking template of the new ad to the specified value.

build()

Creates an Ad. Returns an AdOperation that can be used to get the new ad (or access any associated errors if creation failed).

Return values:

TypeDescription
AdWordsApp.AdOperation The associated ad operation.

withCustomParameters(customParameters)

Sets the custom parameters of the new ad to the specified value.

Custom parameters enable you to create your own ValueTrack parameters that you can assign your own IDs to.

The name of a custom parameter can contain only alphanumeric characters, and custom parameter values may not contain white space. When referring to the custom parameter in final URLs and tracking template, you should surround the custom parameter in braces, and prefix an underscore to its name, e.g. {_param}.

You can have up to 3 custom parameters for an entity. The key and value must not exceed 16 and 200 bytes respectively.

Custom parameters specified at a lower level entity will override the setting specified at a higher level entity, e.g., setting custom parameters at the ad group level overrides the setting at the campaign level, and and custom parameters specified at the ad level override the setting at the ad group level.

See Using Upgraded URLs for more information.

Arguments:

NameTypeDescription
customParameters Object The custom parameters of the ad as a map of the following form: {key1: 'value1', key2: 'value2', key3: 'value3'}.

Return values:

TypeDescription
AdWordsApp.AdBuilder The ad builder with the specified custom parameters.

withDescription1(description1)

Sets the first line of the new ad's description to the specified value. This field is required.

Arguments:

NameTypeDescription
description1 String The first line of the ad description.

Return values:

TypeDescription
AdWordsApp.AdBuilder Ad builder with the specified first description line.

withDescription2(description2)

Sets the second line of the new ad's description to the specified value. This field is required.

Arguments:

NameTypeDescription
description2 String The second line of the ad description.

Return values:

TypeDescription
AdWordsApp.AdBuilder Ad builder with the specified second description line.

withDisplayUrl(displayUrl)

Sets the display URL of the new ad to the specified value. This field is required.

Arguments:

NameTypeDescription
displayUrl String The display URL for the ad.

Return values:

TypeDescription
AdWordsApp.AdBuilder Ad builder with the specified display URL.

withFinalUrl(finalUrl)

Sets the final URL of the new ad to the specified value.

The final URL represents the actual landing page for your ad. The final URL must be the URL of the page that the user ends up on after clicking on your ad, once all the redirects have taken place.

See Using Upgraded URLs for more information.

This field is required.

Arguments:

NameTypeDescription
finalUrl String The final URL for the ad.

Return values:

TypeDescription
AdWordsApp.AdBuilder The ad builder with the specified final URL.

withHeadline(headline)

Sets the headline of the new ad to the specified value. This field is required.

Arguments:

NameTypeDescription
headline String The headline for the ad.

Return values:

TypeDescription
AdWordsApp.AdBuilder Ad builder with the specified headline.

withMobileFinalUrl(mobileFinalUrl)

Sets the mobile final URL of the new ad to the specified value.

The mobile final URL represents the actual landing page for your ad on a mobile device. The final mobile URL must be the URL of the page that the user ends up on after clicking on your ad on a mobile device, once all the redirects have taken place.

See Using Upgraded URLs for more information.

Arguments:

NameTypeDescription
mobileFinalUrl String The mobile final URL for the ad.

Return values:

TypeDescription
AdWordsApp.AdBuilder The ad builder with the specified final URL.

withMobilePreferred(isMobilePreferred)

Sets the new ad's device preference to mobile or clears it. This field is optional and defaults to false.

Arguments:

NameTypeDescription
isMobilePreferred boolean Whether or not this ad should be mobile preferred. If true is passed in, device preference will be set to mobile. If false is passed in, device preference will be set to none.

Return values:

TypeDescription
AdWordsApp.AdBuilder Ad builder with the specified mobile preference.

withTrackingTemplate(trackingTemplate)

Sets the tracking template of the new ad to the specified value.

You can optionally use the tracking template to specify additional tracking parameters or redirects. AdWords will use this template to assemble the actual destination URL to associate with the ad.

A tracking template specified at a lower level entity will override the setting specified at a higher level entity, e.g., a tracking template set at the ad group level overrides the setting at the campaign level, and a tracking template specified at the ad level overrides the setting at the ad group level.

See Using Upgraded URLs for more information.

Arguments:

NameTypeDescription
trackingTemplate String The tracking template for the ad.

Return values:

TypeDescription
AdWordsApp.AdBuilder The ad builder with the specified tracking template.

Send feedback about...

AdWords Scripts
AdWords Scripts
Need help? Visit our support page.