AdWordsApp.​AdCustomizerItem

Represents an ad customizer data item. Each ad customizer item can be seen as one row in an ad customizer source in the Business Data section of the Shared Library. Ad customizer items have attribute values, which are values that correspond to the attributes of the item's source (see AdCustomizerSource). These values can be substituted into an ad with placeholders of the form {=SourceName.AttributeName}. See the feature guide for more information.

Methods:

MemberTypeDescription
clearTargetAdGroup void Clears the set target ad group and campaign.
clearTargetCampaign void Clears the set target campaign.
clearTargetKeyword void Clears the set target keyword.
getAttributeValue Object Returns the value of the named attribute.
getAttributeValues Object Returns a map from attribute name to attribute value.
getEndDate AdWordsApp.AdWordsDate Returns the end date of the ad customizer item.
getEntityType String Returns the type of this entity as a String, in this case, "AdCustomizerItem".
getId long Returns the ID of the ad customizer item.
getSchedules AdWordsApp.ExtensionSchedule[] Returns the scheduling of the ad customizer item.
getStartDate AdWordsApp.AdWordsDate Returns the start date of the ad customizer item.
getTargetAdGroupName String Returns the name of the target ad group, if it is set.
getTargetCampaignName String Returns the name of the target campaign, if it is set.
getTargetKeywordText String Returns the ad customizer item's target keyword text, if it is set.
isMobilePreferred boolean Returns true if the ad customizer item specifies mobile device preference.
remove void Removes the ad customizer item.
setAttributeValue void Sets the named attribute to the given value, or clears its value if null is given.
setAttributeValues void Sets the named attributes to the respective values.
setEndDate void Sets the ad customizer item's end date from either an object containing year, month, and day fields, or an 8-digit string in YYYYMMDD format.
setMobilePreferred void Sets the ad customizer item's device preference.
setSchedules void Sets the ad customizer item scheduling.
setStartDate void Sets the ad customizer item's start date from either an object containing year, month, and day fields, or an 8-digit string in YYYYMMDD format.
setTargetAdGroup void Sets the target ad group and campaign of the ad customizer item.
setTargetCampaign void Sets the target campaign of the ad customizer item.
setTargetKeyword void Sets the target keyword of the ad customizer item.

clearTargetAdGroup()

Clears the set target ad group and campaign. Does nothing if target ad group is not set.

Returns nothing.

clearTargetCampaign()

Clears the set target campaign. Does nothing if the target ad group is set.

Returns nothing.

clearTargetKeyword()

Clears the set target keyword.

Returns nothing.

getAttributeValue(name)

Returns the value of the named attribute. Returns null if the attribute does not have a value. Throws an error if the item's source has no attribute with the given name. The return will match the type of the attribute. An attribute of type number will return a number, an attribute of type text will return a string, and an attribute of type date will return a string in YYYYMMDD HHMMSS format.

Arguments:

NameTypeDescription
name String The name of the attribute to get the value for.

Return values:

TypeDescription
Object The value of the named attribute.

getAttributeValues()

Returns a map from attribute name to attribute value. Attributes with no value are not included in the map. For instance, for an ad customizer item with attribute values item = null, numLeft = 5, and lowCost = "$0.99", calling adCustomizerItem.getAttributeValues() would return {numLeft: 5, lowCost: "$0.99"}.

Return values:

TypeDescription
Object The name-value pairs of all attributes with a value.

getEndDate()

Returns the end date of the ad customizer item. For instance, if the end date of the ad customizer item is May 3, 2013, this would return the following object: {year: 2013, month: 5, day: 3}.

Return values:

TypeDescription
AdWordsApp.AdWordsDate The ad customizer item's end date, or null if there's no end date.

getEntityType()

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

Return values:

TypeDescription
String Type of this entity: "AdCustomizerItem".

getId()

Returns the ID of the ad customizer item.

Return values:

TypeDescription
long The ID of the ad customizer item.

getSchedules()

Returns the scheduling of the ad customizer item.

Return values:

TypeDescription
AdWordsApp.ExtensionSchedule[] The scheduling of the ad customizer item.

getStartDate()

Returns the start date of the ad customizer item. For instance, if the start date of the ad customizer item is May 3, 2013, this would return the following object: {year: 2013, month: 5, day: 3}.

Return values:

TypeDescription
AdWordsApp.AdWordsDate The ad customizer item's start date, or null if there's no start date.

getTargetAdGroupName()

Returns the name of the target ad group, if it is set. Returns null otherwise.

Return values:

TypeDescription
String The name of the target ad group.

getTargetCampaignName()

Returns the name of the target campaign, if it is set. Returns null otherwise.

Return values:

TypeDescription
String The name of the target campaign.

getTargetKeywordText()

Returns the ad customizer item's target keyword text, if it is set. Returns null otherwise. The text returned will be formatted as follows, depending on the match type:
  • shoes - broad match
  • "shoes" - phrase match
  • [leather shoes] - exact match

Return values:

TypeDescription
String The text of the target keyword.

isMobilePreferred()

Returns true if the ad customizer item specifies mobile device preference.

Return values:

TypeDescription
boolean true if the ad customizer item specifies mobile device preference.

remove()

Removes the ad customizer item.

Returns nothing.

setAttributeValue(name, value)

Sets the named attribute to the given value, or clears its value if null is given. The value must be consistent with the type of the attribute:
Type Expected Value Format Example
text String "leather shoes"
number Number (Integer) 42
price String "$4.20"
date String in YYYYMMDD HHMMSS format "20130505 110000". Invalid dates such as "20130005 110000" will result in an error (there is no month 0).
The special attribute custom id also requires that the new value is unique across all items in the ad customizer data source.

The change will fail and report an error if:

  • this item's source has no attribute by the given name,
  • the value is not consistent with the type of the attribute, or
  • for the custom id attribute, another item in the data source has the same value.

Related:

Returns nothing.

Arguments:

NameTypeDescription
name String The name of the attribute to set a value for.
value Object The value to set onto the named attribute.

setAttributeValues(attributeValues)

Sets the named attributes to the respective values. A null value will clear any existing value for the attribute. The value must be consistent with the type of the attribute. See AdCustomizerItem.setAttributeValue for more information on the expected values for each attribute type. The special attribute custom id also requires that the new value is unique across all items in the ad customizer data source.

Examples of the expected value formats for each valid attribute type:

 var attributeValues = {
     item: "leather shoes"         // text
     numLeft: 5,                   // number
     lowCost: "$5.99",             // price
     endDate: "20130401 120000"};  // date
 adCustomizerItem.setAttributeValues(attributeValues);

The change will fail and report an error if:

  • this item's source has no attribute with one of the given names,
  • the value is not consistent with the type of the attribute, or
  • for the custom id attribute, another item in the data source has the same value.

Related:

Returns nothing.

Arguments:

NameTypeDescription
attributeValues Object An object of the attribute values' names and values.

setEndDate(date)

Sets the ad customizer item's end date from either an object containing year, month, and day fields, or an 8-digit string in YYYYMMDD format. For instance, adCustomizerItem.setEndDate("20130503"); is equivalent to adCustomizerItem.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}),
  • the start date now comes after the end date, or
  • it's a date in the past.

Returns nothing.

Arguments:

NameTypeDescription
date Object The new ad customizer item end date.

setMobilePreferred(isMobilePreferred)

Sets the ad customizer item's device preference.

Returns nothing.

Arguments:

NameTypeDescription
isMobilePreferred boolean true sets the device preference to mobile. false clears the device preference.

setSchedules(schedules)

Sets the ad customizer item scheduling. Scheduling of a ad customizer item allows you to control the days of week and times of day during which the ad customizer item will show alongside your ads.

Passing in an empty array clears the scheduling field, causing the ad customizer item to run at all times.

The following example sets the ad customizer item to run on Mondays and Tuesday from 8:00 to 11:00.

 var mondayMorning = {
   dayOfWeek: "MONDAY",
   startHour: 8,
   startMinute: 0,
   endHour: 11,
   endMinute: 0
 };
 var tuesdayMorning = {
   dayOfWeek: "TUESDAY",
   startHour: 8,
   startMinute: 0,
   endHour: 11,
   endMinute: 0
 };

 adCustomizerItem.setSchedules([mondayMorning, tuesdayMorning]);

Returns nothing.

Arguments:

NameTypeDescription
schedules AdWordsApp.ExtensionSchedule[] The new ad customizer item schedules.

setStartDate(date)

Sets the ad customizer item's start date from either an object containing year, month, and day fields, or an 8-digit string in YYYYMMDD format. For instance, adCustomizerItem.setStartDate("20130503"); is equivalent to adCustomizerItem.setStartDate({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}),
  • the given date is after the ad customizer item's end date.

Returns nothing.

Arguments:

NameTypeDescription
date Object The new ad customizer item start date.

setTargetAdGroup(campaignName, adGroupName)

Sets the target ad group and campaign of the ad customizer item. This will fail if a target campaign exists. For instance,
 adCustomizerItem.setTargetCampaign("Campaign");
 adCustomizerItem.setTargetAdGroup("Campaign", "Ad group");
will fail on the second statement, while
 adCustomizerItem.setTargetCampaign("Campaign");
 adCustomizerItem.clearTargetCampaign();
 adCustomizerItem.setTargetAdGroup("Campaign", "Ad group");
will target the ad group "Ad group" and target the campaign "Campaign".

Returns nothing.

Arguments:

NameTypeDescription
campaignName String The name of the campaign that the target ad group belongs to.
adGroupName String The name of the ad group to target.

setTargetCampaign(campaignName)

Sets the target campaign of the ad customizer item. This will fail if a target ad group exists. For instance,
 adCustomizerItem.setTargetAdGroup("Campaign", "Ad group");
 adCustomizerItem.setTargetCampaign("Campaign");
will fail on the second statement, while
 adCustomizerItem.setTargetAdGroup("Campaign", "Ad group");
 adCustomizerItem.clearTargetAdGroup();
 adCustomizerItem.setTargetCampaign("Campaign");
will target the campaign "Campaign".

Returns nothing.

Arguments:

NameTypeDescription
campaignName String The name of the campaign to target.

setTargetKeyword(keyword)

Sets the target keyword of the ad customizer item. Setting the target keyword to one that does not yet exist in your account will not cause an error, but will prevent the ad customizer item from being used to populate ads (until you create the keyword in your account). The keyword should be formatted based on its match type:
  • setTargetKeyword('shoes') - broad match
  • setTargetKeyword('"shoes"') - phrase match
  • setTargetKeyword('[leather shoes]') - exact match

Returns nothing.

Arguments:

NameTypeDescription
keyword String The keyword to target.

Feedback geben zu...

AdWords Scripts
AdWords Scripts