AdsApp.​PhoneNumber

Represents a phone number that can be part of an ad call extension. Visit ourAd Extensionspage for more information on phone numbers and other types of ad extensions.

Methods:

MemberTypeDescription
clearEndDatevoidClears the phone number's end date.
clearStartDatevoidClears the phone number's start date.
getCountryStringReturns the two character country code of the advertiser's phone number.
getEndDateAdsApp.GoogleAdsDateReturns the end date of the phone number, ornull if noend date is set.
getEntityTypeStringReturns the type of this entity as aString, in this case,"PhoneNumber".
getIdStringReturns the ID of the phone number.
getPhoneNumberStringReturns the advertiser's phone number that gets appended to the ad.
getResourceNameStringReturns the resource name of the phone number.
getSchedulesAdsApp.ExtensionSchedule[]Returns the scheduling of the phone number.
getStartDateAdsApp.GoogleAdsDateReturns the start date of the phone number, ornull ifno start date is set.
getStatsForAdsApp.StatsReturns stats for the specified date range.
getStatsForAdsApp.StatsReturns stats for the specified custom date range.
isCallOnlybooleanReturnstrue if this phone number is call only.
isMobilePreferredbooleanReturnstrue if the phone number specifies mobiledevice preference.
setCallOnlyvoidIf set totrue, only the advertiser's phone number will getdisplayed.
setCountryvoidSets the two character country code of the advertiser's phone number.
setEndDatevoidSets the phone number's end date from either an object containingyear, month, and day fields, or an 8-digit string inYYYYMMDDformat.
setMobilePreferredvoidSets the phone number's device preference.
setPhoneNumbervoidSets the advertiser's phone number that gets appended to the ad.
setSchedulesvoidSets the phone number scheduling.
setStartDatevoidSets the phone number's start date from either an object containingyear, month, and day fields, or an 8-digit string inYYYYMMDDformat.

clearEndDate()

Clears the phone number's end date.Deprecated.

Returns nothing.

clearStartDate()

Clears the phone number's start date.
Deprecated.

Returns nothing.

getCountry()

Returns the two character country code of the advertiser's phone number.

Return values:

TypeDescription
StringThe country code of the phone number.

getEndDate()

Returns the end date of the phone number, ornull if noend date is set.

For instance, if the end date of the phone number is May 3, 2013,this would return the following object:{year: 2013, month: 5, day:3}.Deprecated.

Return values:

TypeDescription
AdsApp.GoogleAdsDateThe phone number's end date, ornull if there's no end date.

getEntityType()

Returns the type of this entity as aString, in this case,"PhoneNumber".

Return values:

TypeDescription
StringType of this entity:"PhoneNumber".

getId()

Returns the ID of the phone number.

Return values:

TypeDescription
StringThe ID of the phone number.

getPhoneNumber()

Returns the advertiser's phone number that gets appended to the ad.

Return values:

TypeDescription
StringThe phone number as a string.

getResourceName()

Returns the resource name of the phone number.

Return values:

TypeDescription
StringThe resource name of the phone number.

getSchedules()

Returns the scheduling of the phone number.

Return values:

TypeDescription
AdsApp.ExtensionSchedule[]The scheduling of the phone number.

getStartDate()

Returns the start date of the phone number, ornull ifno start date is set.

For instance, if the start date of the phone number is May 3,2013, this would return the following object:{year: 2013, month: 5,day: 3}.Deprecated.

Return values:

TypeDescription
AdsApp.GoogleAdsDateThe phone number's start date, ornull if there's no 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:

varstats=phoneNumber.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 beeither an object containing year, month, and day fields, or an 8-digitstring inYYYYMMDD form. For instance,March 24th,2013 is represented as either{year: 2013, month: 3, day:24} or"20130324". The date range is inclusive on bothends, soforDateRange("20130324", "20130324") defines a rangeof a single day.

Arguments:

NameTypeDescription
dateFromObjectStart date of the date range. Must be either a string inYYYYMMDD form, or an object withyear,month andday properties.
dateToObjectEnd date of the date range. Must be either a string inYYYYMMDD form, or an object withyear,month andday properties.

Return values:

TypeDescription
AdsApp.StatsThe stats for the specified date range.

isCallOnly()

Returnstrue if this phone number is call only. Iftrue, only the advertiser's phone number will get displayed.Iffalse, the link to the advertiser's website will be shownalongside.
Deprecated.This functionality has been deprecated.

Return values:

TypeDescription
booleantrue if this phone number is call only.

isMobilePreferred()

Returnstrue if the phone number specifies mobiledevice preference.
Deprecated.

Return values:

TypeDescription
booleantrue if the phone number specifies mobile device preference.

setCallOnly(callOnly)

If set totrue, only the advertiser's phone number will getdisplayed. If set tofalse, the link to the advertiser'swebsite will be shown as well.
Deprecated.This functionality has been deprecated. See the announcement blog post for more information.

Returns nothing.

Arguments:

NameTypeDescription
callOnlybooleanThe value for call only setting.

setCountry(country)

Sets the two character country code of the advertiser's phone number.

Returns nothing.

Arguments:

NameTypeDescription
countryStringThe new country code for the phone number.

setEndDate(date)

Sets the phone number's end date from either an object containingyear, month, and day fields, or an 8-digit string inYYYYMMDDformat.

For instance,phoneNumber.setEndDate("20130503"); is equivalent tophoneNumber.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.
Deprecated.

Returns nothing.

Arguments:

NameTypeDescription
dateObjectThe new phone number end date.

setMobilePreferred(isMobilePreferred)

Sets the phone number's device preference.
Deprecated.

Returns nothing.

Arguments:

NameTypeDescription
isMobilePreferredbooleantrue sets the device preference to mobile.false clears the device preference.

setPhoneNumber(phoneNumber)

Sets the advertiser's phone number that gets appended to the ad.

Returns nothing.

Arguments:

NameTypeDescription
phoneNumberStringThe phone number as a string.

setSchedules(schedules)

Sets the phone number scheduling. Scheduling of a phone number allows you to control the days of week and times of day during whichthe phone number will show alongside your ads.

Passing in an empty array clears the scheduling field, causing the phone number to run at all times.

The following example sets the phone number to run on Mondays andTuesday from 8:00 to 11:00.

varmondayMorning={dayOfWeek:"MONDAY",startHour:8,startMinute:0,endHour:11,endMinute:0};vartuesdayMorning={dayOfWeek:"TUESDAY",startHour:8,startMinute:0,endHour:11,endMinute:0};phoneNumber.setSchedules([mondayMorning,tuesdayMorning]);

Returns nothing.

Arguments:

NameTypeDescription
schedulesAdsApp.ExtensionSchedule[]The new phone number schedules.

setStartDate(date)

Sets the phone number's start date from either an object containingyear, month, and day fields, or an 8-digit string inYYYYMMDDformat.

For instance,phoneNumber.setStartDate("20130503"); is equivalent tophoneNumber.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 phone number's end date.
Deprecated.

Returns nothing.

Arguments:

NameTypeDescription
dateObjectThe new phone number start date.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-14 UTC.