AdsApp.​Ad

Represents a Google Ads ad.

Methods:

MemberTypeDescription
applyLabel void Applies a label to the ad.
asType AdsApp.AdViewSpace Returns an AdViewSpace, which provides access to type-specific fields of the ad.
enable void Enables the ad.
getAdGroup AdsApp.AdGroup Returns the ad group to which this ad belongs.
getBaseAdGroup AdsApp.AdGroup Returns the base ad group to which this ad belongs.
getBaseCampaign AdsApp.Campaign Returns the base campaign to which this ad belongs.
getCampaign AdsApp.Campaign Returns the campaign to which this ad belongs or null if it does not belong to a search or display campaign.
getDescription1 String Returns the first line of the ad description or null if the ad is not a text ad.
getDescription2 String Returns the second line of the ad description or null if the ad is not a text ad.
getDisplayUrl String Returns the display URL of the ad.
getEntityType String Returns the type of this entity as a String, in this case, "Ad".
getHeadline String Returns the headline of the ad or null if the ad is not a text ad.
getId String Returns the ID of the ad.
getPolicyApprovalStatus String Returns the policy approval status of the ad.
getPolicyTopics AdsApp.PolicyTopic[] Returns the list of policy topics associated with the ad.
getResourceName String Returns the resource name of the ad.
getStatsFor AdsApp.Stats Returns stats for the specified date range.
getStatsFor AdsApp.Stats Returns stats for the specified custom date range.
getType String Returns the type of the ad.
isEnabled boolean Returns true if the ad is enabled.
isMobilePreferred boolean Returns true if the ad specifies mobile device preference or false otherwise.
isPaused boolean Returns true if the ad is paused.
isType AdsApp.AdTypeSpace Returns an AdTypeSpace, which determines the type of the ad.
labels AdsApp.LabelSelector Creates a selector of all labels applied to the ad.
pause void Pauses the ad.
remove void Removes the ad.
removeLabel void Removes a label from the ad.
urls AdsApp.AdUrls Provides access to this ad's URL fields.

applyLabel(name)

Applies a label to the ad. name of the label is case-sensitive. Operation will fail if the label with the specified name does not already exist in the account.

Note that the ad cannot have more than 50 labels.

Returns nothing.

Arguments:

NameTypeDescription
name String Name of the label to apply.

asType()

Returns an AdViewSpace, which provides access to type-specific fields of the ad.

Return values:

TypeDescription
AdsApp.AdViewSpace An AdViewSpace.

enable()

Enables the ad.

Returns nothing.

getAdGroup()

Returns the ad group to which this ad belongs.

Return values:

TypeDescription
AdsApp.AdGroup The ad group to which this ad belongs.

getBaseAdGroup()

Returns the base ad group to which this ad belongs.

Return values:

TypeDescription
AdsApp.AdGroup The base ad group to which this ad belongs.

getBaseCampaign()

Returns the base campaign to which this ad belongs.

Return values:

TypeDescription
AdsApp.Campaign The base campaign to which this ad belongs.

getCampaign()

Returns the campaign to which this ad belongs or null if it does not belong to a search or display campaign.

Return values:

TypeDescription
AdsApp.Campaign The campaign to which this ad belongs or null if it does not belong to a search or display campaign.

getDescription1()

Returns the first line of the ad description or null if the ad is not a text ad.

Return values:

TypeDescription
String The first line of the ad description or null.

getDescription2()

Returns the second line of the ad description or null if the ad is not a text ad.

Return values:

TypeDescription
String The second line of the ad description or null.

getDisplayUrl()

Returns the display URL of the ad. Returns null for some types of ads.

Return values:

TypeDescription
String The display URL of the ad or null.

getEntityType()

Returns the type of this entity as a String, in this case, "Ad".

Return values:

TypeDescription
String Type of this entity: "Ad".

getHeadline()

Returns the headline of the ad or null if the ad is not a text ad.

Return values:

TypeDescription
String The headline of the ad or null.

getId()

Returns the ID of the ad.

Ad IDs may be shared across ad groups. In order to uniquely identify one ad, one must specify both its ad group ID and its creative ID.

Return values:

TypeDescription
String The ID of the ad.

getPolicyApprovalStatus()

Returns the policy approval status of the ad. For a full list of policy approval statuses, please see the Google Ads API documentation on policy approval statuses.

Return values:

TypeDescription
String The policy approval status of the ad.

getPolicyTopics()

Returns the list of policy topics associated with the ad.

Return values:

TypeDescription
AdsApp.PolicyTopic[] The policy topics of the ad.

getResourceName()

Returns the resource name of the ad.

Return values:

TypeDescription
String The resource name of the ad.

getStatsFor(dateRange)

Returns stats for the specified date range. Supported values:

TODAY, YESTERDAY, LAST_7_DAYS, THIS_WEEK_SUN_TODAY, LAST_WEEK, LAST_14_DAYS, LAST_30_DAYS, LAST_BUSINESS_WEEK, LAST_WEEK_SUN_SAT, THIS_MONTH, LAST_MONTH, ALL_TIME.

Example:

var stats = ad.getStatsFor("THIS_MONTH");

Arguments:

NameTypeDescription
dateRange String Date range for which the stats are requested.

Return values:

TypeDescription
AdsApp.Stats The stats for the specified date range.

getStatsFor(dateFrom, dateTo)

Returns stats for the specified custom date range. Both parameters can be either an object containing year, month, and day fields, or an 8-digit string in YYYYMMDD form. For instance, March 24th, 2013 is represented as either {year: 2013, month: 3, day: 24} or "20130324". The date range is inclusive on both ends, so forDateRange("20130324", "20130324") defines a range of a single day.

Arguments:

NameTypeDescription
dateFrom Object Start date of the date range. Must be either a string in YYYYMMDD form, or an object with year, month and day properties.
dateTo Object End date of the date range. Must be either a string in YYYYMMDD form, or an object with year, month and day properties.

Return values:

TypeDescription
AdsApp.Stats The stats for the specified date range.

getType()

Returns the type of the ad. Possible values: EXPANDED_TEXT_AD, IMAGE_AD, MOBILE_AD, MOBILE_IMAGE_AD, PRODUCT_AD, RICH_MEDIA_AD, TEMPLATE_AD, TEXT_AD.

We recommend using Ad.isType for fully supported types.

Return values:

TypeDescription
String The type of the ad.

isEnabled()

Returns true if the ad is enabled.

Return values:

TypeDescription
boolean true if the ad is enabled.

isMobilePreferred()

Returns true if the ad specifies mobile device preference or false otherwise.

Return values:

TypeDescription
boolean Whether the ad is mobile-preferred.

isPaused()

Returns true if the ad is paused.

Return values:

TypeDescription
boolean true if the ad is paused.

isType()

Returns an AdTypeSpace, which determines the type of the ad.

Return values:

TypeDescription
AdsApp.AdTypeSpace An AdTypeSpace.

labels()

Creates a selector of all labels applied to the ad.

Return values:

TypeDescription
AdsApp.LabelSelector Selector of all labels applied to the ad.

pause()

Pauses the ad.

Returns nothing.

remove()

Removes the ad.

Returns nothing.

removeLabel(name)

Removes a label from the ad. name of the label is case-sensitive. Operation will fail if the label with the specified name does not already exist in the account.

Returns nothing.

Arguments:

NameTypeDescription
name String Name of the label.

urls()

Provides access to this ad's URL fields. See Using Upgraded URLs for more information.

Return values:

TypeDescription
AdsApp.AdUrls Access to this ad's URL fields.