AdsApp.​Campaign

Represents a Google Ads campaign.

Methods:

MemberTypeDescription
adGroupsAdsApp.AdGroupSelectorReturns the selector of all ad groups in the campaign.
addAdScheduleAdsApp.AdScheduleOperationCreates an ad schedule criterion from an ad schedule object.
addAdScheduleAdsApp.AdScheduleOperationCreates an ad schedule criterion.
addCalloutAdsApp.CalloutOperationAdds a callout extension to this campaign.
addExcludedPlacementListvoidAdds a excluded placement list to this campaign.
addLocationAdsApp.TargetedLocationOperationCreates a location target in this campaign from a location ID.
addLocationAdsApp.TargetedLocationOperationCreates a location target in this campaign from a location.
addLocationAdsApp.TargetedLocationOperationCreates a location target in this campaign from a location JSON.
addLocationAdsApp.TargetedLocationOperationCreates a location target in this campaign from a location ID and bid modifier.
addMobileAppAdsApp.MobileAppOperationAdds a mobile app extension to this campaign.
addNegativeKeywordListvoidAdds a negative keyword list to this campaign.
addPhoneNumberAdsApp.PhoneNumberOperationAdds a phone number extension to this campaign.
addPriceAdsApp.PriceOperationAdds a price extension to this campaign.
addProximityAdsApp.TargetedProximityOperationCreates a proximity target in this campaign from a proximity object.
addProximityAdsApp.TargetedProximityOperationCreates a proximity target in this campaign.
addSitelinkAdsApp.SitelinkOperationAdds a sitelink extension to this campaign.
addSnippetAdsApp.SnippetOperationAdds a snippet extension to this campaign.
adsAdsApp.AdSelectorReturns the selector of all ads in the campaign.
applyLabelvoidApplies a label to the campaign.
biddingAdsApp.CampaignBiddingProvides access to this campaign's bidding fields.
createNegativeKeywordvoidCreates a new campaign-level negative keyword with the specified text.
displayAdsApp.CampaignDisplayProvides access to this campaign's display criteria: Audience, ExcludedAudience, DisplayKeyword, ExcludedDisplayKeyword, Placement, ExcludedPlacement, Topic, and ExcludedTopic.
draftCampaignsAdsApp.CampaignSelectorReturns a selector of draft campaigns that have this campaign as their base campaign.
draftsAdsApp.DraftSelectorReturns a selector of drafts that have this campaign as their base campaign.
enablevoidEnables the campaign.
excludeLocationAdsApp.ExcludedLocationOperationCreates a location exclusion in this campaign.
excludeLocationAdsApp.ExcludedLocationOperationCreates a location exclusion in this campaign.
excludeLocationAdsApp.ExcludedLocationOperationCreates a location exclusion in this campaign for the specified JSON.
excludedPlacementListsAdsApp.ExcludedPlacementListSelectorReturns a selector of excluded placement lists associated with this campaign.
experimentCampaignsAdsApp.CampaignSelectorReturns a selector of experiment campaigns that have this campaign as their base campaign.
experimentsAdsApp.ExperimentSelectorReturns a selector of experiments that have this campaign as their base campaign.
extensionsAdsApp.CampaignExtensionsProvides access to this campaign's extensions: CampaignCallout, CampaignMobileApp, CampaignPhoneNumber, CampaignSitelink, and CampaignSnippet.
getAdRotationTypeStringReturns the ad rotation type of the campaign.
getBaseCampaignAdsApp.CampaignReturns the base campaign to which this campaign belongs.
getBiddingStrategyTypeStringReturns the bidding strategy type of the campaign.
getBudgetAdsApp.BudgetReturns the budget of the campaign.
getEndDateAdsApp.GoogleAdsDateReturns the campaign's end date, or null if there is no end date.
getEntityTypeStringReturns the type of this entity as a String, in this case, "Campaign".
getIdStringReturns the ID of the campaign.
getNameStringReturns the name of the campaign.
getResourceNameStringReturns the resource name of the campaign.
getStartDateAdsApp.GoogleAdsDateReturns the campaign's start date.
getStatsForAdsApp.StatsReturns stats for the specified date range.
getStatsForAdsApp.StatsReturns stats for the specified custom date range.
isBaseCampaignbooleanReturns true if the campaign is a base (i.e.
isDraftCampaignbooleanReturns true if the campaign is a draft campaign.
isEnabledbooleanReturns true if the campaign is enabled.
isExperimentCampaignbooleanReturns true if the campaign is an experiment campaign.
isPausedbooleanReturns true if the campaign is paused.
isRemovedbooleanReturns true if the campaign is removed.
keywordsAdsApp.KeywordSelectorReturns the selector of all keywords in the campaign.
labelsAdsApp.LabelSelectorCreates a selector of all labels applied to the campaign.
negativeKeywordListsAdsApp.NegativeKeywordListSelectorReturns a selector of negative keyword lists associated with this campaign.
negativeKeywordsAdsApp.NegativeKeywordSelectorReturns a selector of the campaign-level negative keywords belonging to this campaign.
newAdGroupBuilderAdsApp.AdGroupBuilderReturns a new ad group builder for this campaign.
newDraftBuilderAdsApp.DraftBuilderReturns a new draft builder with this campaign as the base campaign.
pausevoidPauses the campaign.
recommendationsAdsApp.RecommendationSelectorReturns the selector of all recommendations for this campaign.
removeCalloutvoidRemoves a callout extension from this campaign.
removeExcludedPlacementListvoidRemoves a excluded placement list from this campaign.
removeLabelvoidRemoves a label from the campaign.
removeMobileAppvoidRemoves a mobile app extension from this campaign.
removeNegativeKeywordListvoidRemoves a negative keyword list from this campaign.
removePhoneNumbervoidRemoves a phone number extension from this campaign.
removePricevoidRemoves a price extension from this campaign.
removeSitelinkvoidRemoves a sitelink extension from this campaign.
removeSnippetvoidRemoves a snippet extension from this campaign.
setAdRotationTypevoidSets the ad rotation type of the campaign.
setEndDatevoidSets the campaign's end date from either an object containing year, month, and day fields, or an 8-digit string in YYYYMMDD format.
setNamevoidSets the name of the campaign.
setStartDatevoidSets the campaign's start date from either an object containing year, month, and day fields, or an 8-digit string in YYYYMMDD format.
targetingAdsApp.CampaignTargetingProvides access to campaign-level targeting criteria: device targeting, ad scheduling, location targeting, and audiences.
urlsAdsApp.CampaignUrlsProvides access to this campaign's URL fields.

adGroups()

Returns the selector of all ad groups in the campaign.

Return values:

TypeDescription
AdsApp.AdGroupSelectorThe selector of all ad groups in the campaign.

addAdSchedule(adSchedule)

Creates an ad schedule criterion from an ad schedule object. Once created, the campaign will start showing ads during the specified time.

When called with one argument, addAdSchedule supports two kinds of input:

  • Existing AdSchedule objects, perhaps from another campaign:
    var campaigns = AdsApp.campaigns().get();
    var campaign1 = campaigns.next();
    var campaign2 = campaigns.next();
    var schedule = campaign1.targeting().adSchedules().get().next();
    campaign2.addAdSchedule(schedule);
  • Plain JavaScript objects describing an ad schedule. For instance, this will create an ad schedule covering Saturday mornings:
    var campaign = AdsApp.campaigns().get().next();
    campaign.addAdSchedule({
      dayOfWeek: "SATURDAY",
      startHour: 7,
      startMinute: 0,
      endHour: 11,
      endMinute: 0,
      bidModifier: 1.1
    });
    This will look at the following properties of the given object:
    • dayOfWeek: Required. Must be one of "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", or "SUNDAY".
    • startHour and startMinute: Required. The starting time of this segment of the ad schedule. startHour must be an integer between 0 and 23, and startMinute must be either 0, 15, 30, or 45. For instance, a startHour of 18 and a startMinute of 30 would result in an ad schedule starting at 6:30PM. Acceptable starting times range from 00:00 to 23:45.
    • endHour and endMinute: Required. The ending time of this segment of the ad schedule. endHour must be an integer between 0 and 24, and endMinute must be either 0, 15, 30, or 45. For instance, a endHour of 18 and a endMinute of 30 would result in an ad schedule ending at 6:30PM. Acceptable ending times range from 00:15 to 24:00.
    • bidModifier: Optional. The bid modifier for this segment of the ad schedule.

One thing to keep in mind is that, by default, campaigns have no ad schedule criteria and hence serve ads at all times. Adding the first ad schedule to a campaign will cause ads to be shown during that time only.

There is a limit of 6 ad schedules for each day of the week — for instance, splitting up each day into 6 4-hour-long periods is supported, but splitting up each day into 24 1-hour-long periods is not.

Arguments:

NameTypeDescription
adScheduleObjectThe schedule to create.

Return values:

TypeDescription
AdsApp.AdScheduleOperationThe associated ad schedule operation.

addAdSchedule(dayOfWeek, startHour, startMinute, endHour, endMinute, bidModifier)

Creates an ad schedule criterion. Once created, the campaign will start showing ads during the specified time.

For instance, this will create an ad schedule covering Saturday mornings:

var campaign = AdsApp.campaigns().get().next();
campaign.addAdSchedule("SATURDAY", 7, 0, 11, 0);

This will create the same schedule, but with a bid modifier of 1.1:

var campaign = AdsApp.campaigns().get().next();
campaign.addAdSchedule("SATURDAY", 7, 0, 11, 0, 1.1);

One thing to keep in mind is that, by default, campaigns have no ad schedule criteria and hence serve ads at all times. Adding the first ad schedule to a campaign will cause ads to be shown during that time only.

There is a limit of 6 ad schedules for each day of the week — for instance, splitting up each day into 6 4-hour-long periods is supported, but splitting up each day into 24 1-hour-long periods is not.

Arguments:

NameTypeDescription
dayOfWeekStringThe day of week. Must be one of "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", or "SUNDAY".
startHourintThe start hour. Must be an integer between 0 and 23. Acceptable starting times range from 00:00 to 23:45.
startMinuteintThe start minute. Must be either 0, 15, 30, or 45. Acceptable starting times range from 00:00 to 23:45.
endHourintThe end hour. Must be an integer between 0 and 24. Acceptable ending times range from 00:15 to 24:00.
endMinuteintThe end minute. Must be either 0, 15, 30, or 45. Acceptable ending times range from 00:15 to 24:00.
bidModifierdoubleOptional. The bid modifier to use for the newly created ad schedule.

Return values:

TypeDescription
AdsApp.AdScheduleOperationThe associated ad schedule operation.

addCallout(calloutExtension)

Adds a callout extension to this campaign. See also Extensions.newCalloutBuilder()

Arguments:

NameTypeDescription
calloutExtensionAdsApp.CalloutThe callout to add to this campaign.

Return values:

TypeDescription
AdsApp.CalloutOperationThe associated callout operation.

addExcludedPlacementList(excludedPlacementList)

Adds a excluded placement list to this campaign.

Returns nothing.

Arguments:

NameTypeDescription
excludedPlacementListAdsApp.ExcludedPlacementListThe excluded placement list to be added to this campaign.

addLocation(locationId)

Creates a location target in this campaign from a location ID. Once created, the campaign will start showing ads to the location with the given location ID.

You must specify a location ID. For a list of locations and their corresponding IDs, see the API documentation on geotargeting.

Arguments:

NameTypeDescription
locationIdintThe location ID to target.

Return values:

TypeDescription
AdsApp.TargetedLocationOperationThe associated targeted location operation.

addLocation(location)

Creates a location target in this campaign from a location. Once created, the campaign will start showing ads to the location with the given location ID.

You must specify an existing TargetedLocation object, perhaps from another campaign:

var campaigns = AdsApp.campaigns().get();
var campaign1 = campaigns.next();
var campaign2 = campaigns.next();
var location = campaign1.targeting().targetedLocations().get().next();
campaign2.addLocation(location);

Arguments:

NameTypeDescription
locationAdsApp.TargetedLocationThe location to target.

Return values:

TypeDescription
AdsApp.TargetedLocationOperationThe associated targeted location operation.

addLocation(location)

Creates a location target in this campaign from a location JSON. Once created, the campaign will start showing ads to the location with the given location ID.

You must specify a plain JavaScript object describing a location. For instance, this would create a location target for Tennessee:

var campaign = AdsApp.campaigns().get().next();
campaign.addLocation({
  id: 21175,
  bidModifier: 1.2,
});
This will look at the following properties of the given object:
  • id: Required. The ID of the location to target. For a list of locations and their corresponding IDs, see the API documentation on geotargeting.
  • bidModifier: Optional. The bid modifier for this location.

Arguments:

NameTypeDescription
locationObjectJSON representation of the location to target.

Return values:

TypeDescription
AdsApp.TargetedLocationOperationThe associated targeted location operation.

addLocation(locationId, bidModifier)

Creates a location target in this campaign from a location ID and bid modifier. Once created, the campaign will start showing ads to the location with the given location ID.

For instance, this will create a location target for Tennessee with a bid modifier of 1.15:

var campaign = AdsApp.campaigns().get().next();
campaign.addLocation(21175, 1.15);

Arguments:

NameTypeDescription
locationIdintThe ID of the location to target. For a list of locations and their corresponding IDs, see the API documentation on geotargeting.
bidModifierdoubleThe desired bid modifier for the new location target.

Return values:

TypeDescription
AdsApp.TargetedLocationOperationThe associated targeted location operation.

addMobileApp(mobileAppExtension)

Adds a mobile app extension to this campaign. See also Extensions.newMobileAppBuilder()

Arguments:

NameTypeDescription
mobileAppExtensionAdsApp.MobileAppThe mobile app to add to this campaign.

Return values:

TypeDescription
AdsApp.MobileAppOperationThe associated mobile app operation.

addNegativeKeywordList(negativeKeywordList)

Adds a negative keyword list to this campaign.

Returns nothing.

Arguments:

NameTypeDescription
negativeKeywordListAdsApp.NegativeKeywordListThe negative keyword list to be added to this campaign.

addPhoneNumber(phoneNumberExtension)

Adds a phone number extension to this campaign. See also Extensions.newPhoneNumberBuilder()

Arguments:

NameTypeDescription
phoneNumberExtensionAdsApp.PhoneNumberThe phone number to add to this campaign.

Return values:

TypeDescription
AdsApp.PhoneNumberOperationThe associated phone number operation.

addPrice(priceExtension)

Adds a price extension to this campaign. See also Extensions.newPriceBuilder().

Arguments:

NameTypeDescription
priceExtensionAdsApp.PriceThe price to add to this campaign.

Return values:

TypeDescription
AdsApp.PriceOperationThe associated price operation.

addProximity(proximity)

Creates a proximity target in this campaign from a proximity object. Once created, the campaign will start showing ads to geographical points within the specified radius of the specified central point.

When called with one argument, addProximity supports two kinds of input:

  • Existing TargetedProximity objects, perhaps from another campaign:
    var campaigns = AdsApp.campaigns().get();
    var campaign1 = campaigns.next();
    var campaign2 = campaigns.next();
    var proximity = campaign1.targeting().targetedProximities().get().next();
    campaign2.addProximity(proximity);
  • Plain JavaScript objects describing a proximity. For instance, this would create a proximity targeting 20km around Google headquarters:
    var campaign = AdsApp.campaigns().get().next();
    campaign.addProximity({
      latitude: 37.423021,
      longitude: -122.083739,
      radius: 20,
      radiusUnits: "KILOMETERS",
      bidModifier: 0.75,
      address: {
        streetAddress: "1600 Amphitheatre Parkway",
        cityName: "Mountain View",
        provinceName: "California",
        provinceCode: "CA",
        postalCode: "94043",
        countryCode: "US"
      }
    });
    This will look at the following properties of the given object:
    • latitude and longitude: Required. The central geographic point of the proximity to target.
    • radius and radiusUnits: Required. The radius around the central point to target. radiusUnits must be either "MILES" or "KILOMETERS".
    • bidModifier: Optional. The bid modifier for this proximity.
    • address: Optional. The address associated with the central geographical point.

      If present, this is expected to be an object, which contains any of streetAddress, streetAddress2, cityName, provinceName, provinceCode, postalCode, and countryCode as properties with string values. This corresponds to the Address objects returned by existing proximity targets.

      There is no validation to check that the address actually belongs to the given latitude and longitude. It has no functionality except to change what shows up in the Campaign Management interface.

Arguments:

NameTypeDescription
proximityObjectThe proximity to target.

Return values:

TypeDescription
AdsApp.TargetedProximityOperationThe associated targeted proximity operation.

addProximity(latitude, longitude, radius, radiusUnits, optArgs)

Creates a proximity target in this campaign. Once created, the campaign will start showing ads to geographical points within the specified radius of the specified central point.

For instance, this will create a proximity targeting 20km around Google headquarters:

var campaign = AdsApp.campaigns().get().next();
campaign.addProximity(37.423021, -122.083739, 20, "KILOMETERS");
Similarly, to create the same proximity target with a bid modifier and address:
campaign.addProximity(37.423021, -122.083739, 20, "KILOMETERS", {
  bidModifier: 1.15,
  address: {
    streetAddress: "1600 Amphitheatre Parkway",
    cityName: "Mountain View",
    provinceName: "California",
    provinceCode: "CA",
    postalCode: "94043",
    countryCode: "US"
  }
});

Arguments:

NameTypeDescription
latitudedoubleThe latitude of the central point.
longitudedoubleThe longitude of the central point.
radiusdoubleThe radius of the proximity target.
radiusUnitsStringThe units of the radius, either "MILES" or "KILOMETERS".
optArgsObjectOptional. Either a number, which will be interpreted as the desired bid modifier for the proximity, or an object containing extra additional arguments.

For TargetedProximities, there are two supported optional arguments:

  • bidModifier: The bid modifier for this proximity.
  • address: The address associated with the central geographical point.

    If present, this is expected to be an object, which contains any of streetAddress, streetAddress2, cityName, provinceName, provinceCode, postalCode, and countryCode as properties with string values. This corresponds to the Address objects returned by existing proximity targets.

    There is no validation to check that the address actually belongs to the given latitude and longitude. It has no functionality except to change what shows up in the Campaign Management interface.

Return values:

TypeDescription
AdsApp.TargetedProximityOperationThe associated targeted proximity operation.
Adds a sitelink extension to this campaign. See also Extensions.newSitelinkBuilder()

Arguments:

NameTypeDescription
sitelinkExtensionAdsApp.SitelinkThe sitelink to add to this campaign.

Return values:

TypeDescription
AdsApp.SitelinkOperationThe associated sitelink operation.

addSnippet(snippetExtension)

Adds a snippet extension to this campaign. See also Extensions.newSnippetBuilder()

Arguments:

NameTypeDescription
snippetExtensionAdsApp.SnippetThe snippet to add to this campaign.

Return values:

TypeDescription
AdsApp.SnippetOperationThe associated snippet operation.

ads()

Returns the selector of all ads in the campaign.

Return values:

TypeDescription
AdsApp.AdSelectorThe selector of all ads in the campaign.

applyLabel(name)

Applies a label to the campaign. 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 campaign cannot have more than 50 labels.

Returns nothing.

Arguments:

NameTypeDescription
nameStringName of the label to apply.

bidding()

Provides access to this campaign's bidding fields.

Return values:

TypeDescription
AdsApp.CampaignBiddingAccess to this campaign's bidding fields.

createNegativeKeyword(keywordText)

Creates a new campaign-level negative keyword with the specified text.

Match type for the new negative keyword is specified as follows:

  • createNegativeKeyword("shoes") - broad match.
  • createNegativeKeyword("\"shoes\"") - phrase match.
  • createNegativeKeyword("[leather shoes]") - exact match.

Returns nothing.

Arguments:

NameTypeDescription
keywordTextStringThe text of the new negative keyword.

display()

Provides access to this campaign's display criteria: Audience, ExcludedAudience, DisplayKeyword, ExcludedDisplayKeyword, Placement, ExcludedPlacement, Topic, and ExcludedTopic.

Return values:

TypeDescription
AdsApp.CampaignDisplayAccess to this campaign's display criteria.

draftCampaigns()

Returns a selector of draft campaigns that have this campaign as their base campaign.

Return values:

TypeDescription
AdsApp.CampaignSelectorA selector of draft campaigns that have this campaign as their base campaign.

drafts()

Returns a selector of drafts that have this campaign as their base campaign.

Return values:

TypeDescription
AdsApp.DraftSelectorA selector of drafts that have this campaign as their base campaign.

enable()

Enables the campaign.

Returns nothing.

excludeLocation(location)

Creates a location exclusion in this campaign. Once created, the campaign will not show ads to the location with the given location ID.

You must specify an existing ExcludedLocation object, perhaps from another campaign:

var campaigns = AdsApp.campaigns().get();
var campaign1 = campaigns.next();
var campaign2 = campaigns.next();
var location = campaign1.targeting().excludedLocations().get().next();
campaign2.excludeLocation(location);

Arguments:

NameTypeDescription
locationAdsApp.ExcludedLocationThe location to exclude.

Return values:

TypeDescription
AdsApp.ExcludedLocationOperationThe associated excluded location operation.

excludeLocation(locationId)

Creates a location exclusion in this campaign. Once created, the campaign will not show ads to the location with the given location ID.

You must specify a location ID. For a list of locations and their corresponding IDs, see the API documentation on geotargeting:

var campaign = AdsApp.campaigns().get().next();
campaign.excludeLocation(21175);

Arguments:

NameTypeDescription
locationIdintThe ID of the location to exclude.

Return values:

TypeDescription
AdsApp.ExcludedLocationOperationThe associated excluded location operation.

excludeLocation(location)

Creates a location exclusion in this campaign for the specified JSON. Once created, the campaign will not show ads to the location with the given location ID.

You must specify a plain JavaScript object describing a location. For instance, this would create a location exclusion for Tennessee:

var campaign = AdsApp.campaigns().get().next();
campaign.excludeLocation({
  id: 21175
});
The only field of the object which will be looked at is id, which represents the location ID.

Arguments:

NameTypeDescription
locationObjectJSON representation of the location to exclude.

Return values:

TypeDescription
AdsApp.ExcludedLocationOperationThe associated excluded location operation.

excludedPlacementLists()

Returns a selector of excluded placement lists associated with this campaign.

Return values:

TypeDescription
AdsApp.ExcludedPlacementListSelectorA selector of excluded placement lists associated with this campaign.

experimentCampaigns()

Returns a selector of experiment campaigns that have this campaign as their base campaign.

Return values:

TypeDescription
AdsApp.CampaignSelectorA selector of experiment campaigns that have this campaign as their base campaign.

experiments()

Returns a selector of experiments that have this campaign as their base campaign.

Return values:

TypeDescription
AdsApp.ExperimentSelectorA selector of experiments that have this campaign as their base campaign.

extensions()

Provides access to this campaign's extensions: CampaignCallout, CampaignMobileApp, CampaignPhoneNumber, CampaignSitelink, and CampaignSnippet.

Return values:

TypeDescription
AdsApp.CampaignExtensionsAccess to this campaign's extensions.

getAdRotationType()

Returns the ad rotation type of the campaign. Possible return values:

OPTIMIZE, CONVERSION_OPTIMIZE, ROTATE, ROTATE_FOREVER

Return values:

TypeDescription
StringAd rotation type of the campaign.

getBaseCampaign()

Returns the base campaign to which this campaign belongs.

Return values:

TypeDescription
AdsApp.CampaignThe base campaign to which this campaign belongs.

getBiddingStrategyType()

Returns the bidding strategy type of the campaign. Possible return values:

MANUAL_CPC, MANUAL_CPM, TARGET_CPA, TARGET_SPEND, TARGET_ROAS, MAXIMIZE_CONVERSIONS, MAXIMIZE_CONVERSION_VALUE, TARGET_IMPRESSION_SHARE

Return values:

TypeDescription
StringType of campaign's bidding strategy.

getBudget()

Returns the budget of the campaign. In order to change the campaign's budget, use Budget.setAmount(double).

Return values:

TypeDescription
AdsApp.BudgetBudget of the campaign.

getEndDate()

Returns the campaign's end date, or null if there is no end date.

For instance, if a campaign ended on May 3, 2013, this would return the following object: {year: 2013, month: 5, day: 3}.

Return values:

TypeDescription
AdsApp.GoogleAdsDateThe campaign's end date, or null if there's no end date.

getEntityType()

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

Return values:

TypeDescription
StringType of this entity: "Campaign".

getId()

Returns the ID of the campaign.

Return values:

TypeDescription
StringThe ID of the campaign.

getName()

Returns the name of the campaign.

Return values:

TypeDescription
StringName of the campaign.

getResourceName()

Returns the resource name of the campaign.

Return values:

TypeDescription
StringThe resource name of the campaign.

getStartDate()

Returns the campaign's start date.

For instance, if a campaign started on May 3, 2013, this would return the following object: {year: 2013, month: 5, day: 3}.

Return values:

TypeDescription
AdsApp.GoogleAdsDateThe campaign's start date.

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 = campaign.getStatsFor("THIS_MONTH");

Arguments:

NameTypeDescription
dateRangeStringDate range for which the stats are requested.

Return values:

TypeDescription
AdsApp.StatsThe 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
dateFromObjectStart date of the date range. Must be either a string in YYYYMMDD form, or an object with year, month and day properties.
dateToObjectEnd 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.StatsThe stats for the specified date range.

isBaseCampaign()

Returns true if the campaign is a base (i.e. regular) campaign.

Return values:

TypeDescription
booleantrue if the campaign is a base (i.e. regular) campaign.

isDraftCampaign()

Returns true if the campaign is a draft campaign.

Return values:

TypeDescription
booleantrue if the campaign is a draft campaign.

isEnabled()

Returns true if the campaign is enabled.

Return values:

TypeDescription
booleantrue if the campaign is enabled.

isExperimentCampaign()

Returns true if the campaign is an experiment campaign.

Return values:

TypeDescription
booleantrue if the campaign is an experiment campaign.

isPaused()

Returns true if the campaign is paused.

Return values:

TypeDescription
booleantrue if the campaign is paused.

isRemoved()

Returns true if the campaign is removed.

Return values:

TypeDescription
booleantrue if the campaign is removed.

keywords()

Returns the selector of all keywords in the campaign.

Return values:

TypeDescription
AdsApp.KeywordSelectorThe selector of all keywords in the campaign.

labels()

Creates a selector of all labels applied to the campaign.

Return values:

TypeDescription
AdsApp.LabelSelectorSelector of all labels applied to the campaign.

negativeKeywordLists()

Returns a selector of negative keyword lists associated with this campaign.

Return values:

TypeDescription
AdsApp.NegativeKeywordListSelectorA selector of negative keyword lists associated with this campaign.

negativeKeywords()

Returns a selector of the campaign-level negative keywords belonging to this campaign.

Note that this selector will not return any negative keywords belonging to this campaign's child ad groups — it only returns campaign-level negative keywords.

Return values:

TypeDescription
AdsApp.NegativeKeywordSelectorThe selector of all campaign-level negative keywords in this campaign.

newAdGroupBuilder()

Returns a new ad group builder for this campaign. Once builder.build() is called, the ad group will be created in this campaign.

Return values:

TypeDescription
AdsApp.AdGroupBuilderAd group builder.

newDraftBuilder()

Returns a new draft builder with this campaign as the base campaign.

Return values:

TypeDescription
AdsApp.DraftBuilderA new draft builder with this campaign as the base campaign.

pause()

Pauses the campaign.

Returns nothing.

recommendations()

Returns the selector of all recommendations for this campaign.

Return values:

TypeDescription
AdsApp.RecommendationSelectorThe selector of all recommendations for this campaign.

removeCallout(calloutExtension)

Removes a callout extension from this campaign.

Returns nothing.

Arguments:

NameTypeDescription
calloutExtensionAdsApp.CalloutThe callout to remove from this campaign.

removeExcludedPlacementList(excludedPlacementList)

Removes a excluded placement list from this campaign.

Returns nothing.

Arguments:

NameTypeDescription
excludedPlacementListAdsApp.ExcludedPlacementListThe excluded placement list to be removed from this campaign.

removeLabel(name)

Removes a label from the campaign. 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
nameStringName of the label.

removeMobileApp(mobileAppExtension)

Removes a mobile app extension from this campaign.

Returns nothing.

Arguments:

NameTypeDescription
mobileAppExtensionAdsApp.MobileAppThe mobile app to remove from this campaign.

removeNegativeKeywordList(negativeKeywordList)

Removes a negative keyword list from this campaign.

Returns nothing.

Arguments:

NameTypeDescription
negativeKeywordListAdsApp.NegativeKeywordListThe negative keyword list to be removed from this campaign.

removePhoneNumber(phoneNumberExtension)

Removes a phone number extension from this campaign.

Returns nothing.

Arguments:

NameTypeDescription
phoneNumberExtensionAdsApp.PhoneNumberThe phone number to remove from this campaign.

removePrice(priceExtension)

Removes a price extension from this campaign.

Returns nothing.

Arguments:

NameTypeDescription
priceExtensionAdsApp.PriceThe price to remove from this campaign.
Removes a sitelink extension from this campaign.

Returns nothing.

Arguments:

NameTypeDescription
sitelinkExtensionAdsApp.SitelinkThe sitelink to remove from this campaign.

removeSnippet(snippetExtension)

Removes a snippet extension from this campaign.

Returns nothing.

Arguments:

NameTypeDescription
snippetExtensionAdsApp.SnippetThe snippet to remove from this campaign.

setAdRotationType(adRotationType)

Sets the ad rotation type of the campaign.

For instance, campaign.setAdRotationType("OPTIMIZE"); instructs Google Ads to optimize ad serving based on the campaign's CTR. For more information, see Choose an ad delivery method help article.

Returns nothing.

Arguments:

NameTypeDescription
adRotationTypeStringThe new ad rotation type of the campaign. Must be one of "OPTIMIZE", "CONVERSION_OPTIMIZE", "ROTATE", or "ROTATE_FOREVER".

setEndDate(date)

Sets the campaign's end date from either an object containing year, month, and day fields, or an 8-digit string in YYYYMMDD format.

For instance, campaign.setEndDate("20130503"); is equivalent to campaign.setEndDate({year: 2013, month: 5, day: 3});.

The change will fail and report an error if:

  • the given date is invalid (e.g., {year: 2013, month: 5, day: 55}),
  • it's a date in the past, or
  • it's a date after the latest allowed end date of December 30, 2037.

Returns nothing.

Arguments:

NameTypeDescription
dateObjectThe new campaign end date.

setName(name)

Sets the name of the campaign.

Returns nothing.

Arguments:

NameTypeDescription
nameStringThe new name for the campaign.

setStartDate(date)

Sets the campaign's start date from either an object containing year, month, and day fields, or an 8-digit string in YYYYMMDD format.

For instance, campaign.setStartDate("20130503"); is equivalent to campaign.setStartDate({year: 2013, month: 5, day: 3});.

The change will fail and report an error if:

  • the campaign has already started,
  • the given date is invalid (e.g., {year: 2013, month: 5, day: 55}),
  • the given date is after the campaign's end date,
  • it's a date in the past, or
  • it's a date after the latest allowed end date of December 30, 2037.

Returns nothing.

Arguments:

NameTypeDescription
dateObjectThe new campaign end date.

targeting()

Provides access to campaign-level targeting criteria: device targeting, ad scheduling, location targeting, and audiences.

Return values:

TypeDescription
AdsApp.CampaignTargetingAccess to certain kinds of targeting criteria in this campaign.

urls()

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

Return values:

TypeDescription
AdsApp.CampaignUrlsAccess to this campaign's URL fields.