Page Summary
-
AdsApp.SitelinkBuilder is used to create new Sitelink objects with required fields like final URL and link text.
-
Optional fields like descriptions, dates, and mobile preferences can be set using
withmethods on the builder. -
The
build()method creates a SitelinkOperation which can be checked for success and to retrieve the created sitelink or any errors. -
Various methods like
withCustomParameters,withSchedules, andwithTrackingTemplateallow for detailed configuration of the sitelink.
Example usage:
// Create a sitelink builder . var sitelinkBuilder = AdsApp . extensions () . newSitelinkBuilder (); // Create a sitelink operation . var sitelinkOperation = sitelinkBuilder . withFinalUrl ( "http://www.example.com/join" ) // required . withLinkText ( "Join us now" ) // required . withMobilePreferred ( true ) // optional . build (); // Optional : examine the outcome . The call to isSuccessful () // will block until the operation completes . if ( sitelinkOperation . isSuccessful ()) { // Get the result . var sitelink = sitelinkOperation . getResult (); } else { // Handle the errors . var errors = sitelinkOperation . getErrors (); }
Methods:
| Member | Type | Description |
|---|---|---|
AdsApp.SitelinkOperation
|
Creates a Sitelink . | |
AdsApp.SitelinkBuilder
|
Sets the custom parameters of the new sitelink to the specified value. | |
AdsApp.SitelinkBuilder
|
Sets the first description line of the new sitelink description to the specified value. | |
AdsApp.SitelinkBuilder
|
Sets the second description line of the new sitelink description to the specified value. | |
AdsApp.SitelinkBuilder
|
Sets the sitelink's end date from either an object containing
year, month, and day fields, or an 8-digit string in YYYYMMDD
format. |
|
AdsApp.SitelinkBuilder
|
Sets the final URL of the new sitelink to the specified value. | |
AdsApp.SitelinkBuilder
|
Sets the final URL suffix of the new sitelink to the specified value. | |
AdsApp.SitelinkBuilder
|
Sets the link text of the new sitelink to the specified value. | |
AdsApp.SitelinkBuilder
|
Sets the mobile final URL of the new sitelink to the specified value. | |
AdsApp.SitelinkBuilder
|
Sets the sitelink's device preference to mobile or clears it. | |
AdsApp.SitelinkBuilder
|
Sets the sitelink scheduling. | |
AdsApp.SitelinkBuilder
|
Sets the sitelink's start date from either an object containing
year, month, and day fields, or an 8-digit string in YYYYMMDD
format. |
|
AdsApp.SitelinkBuilder
|
Sets the tracking template of the new sitelink to the specified value. |
build(buildLegacy)
Creates a Sitelink
.
Returns a SitelinkOperation
that can be used to get the new sitelink (or access any
associated errors if creation failed). Defaults to building the type of sitelink that is currently serving. If there are upgraded sitelinks, then an upgraded sitelink will be built by default. If there are only legacy sitelinks, then a legacy sitelink will be built by default. If there are neither, then an upgraded sitelink will be built by default.
Arguments:
| Name | Type | Description |
|---|---|---|
|
buildLegacy
|
boolean
|
If true
, builds a legacy sitelink. If false
, builds an upgraded sitelink. If
unspecified, defaults to building whichever type is currently serving. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkOperation
|
The associated sitelink operation. |
withCustomParameters(customParameters)
Sets the custom parameters of the new sitelink 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 8 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 custom parameters specified at the ad level override the setting at the ad group level.
See Using Upgraded URLs for more information.
Arguments:
| Name | Type | Description |
|---|---|---|
|
customParameters
|
Object
|
The custom parameters of the sitelink as
a map of the following form: {key1: 'value1', key2: 'value2',
key3: 'value3'}
. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
The sitelink builder with the specified custom parameters. |
withDescription1(description1)
Sets the first description line of the new sitelink description to the
specified value. Arguments:
| Name | Type | Description |
|---|---|---|
|
description1
|
String
|
The first description line. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
Sitelink builder with the specified description line 1. |
withDescription2(description2)
Sets the second description line of the new sitelink description to the
specified value. Arguments:
| Name | Type | Description |
|---|---|---|
|
description2
|
String
|
The second description line. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
Sitelink builder with the specified description line 2. |
withEndDate(date)
Sets the sitelink's end date from either an object containing
year, month, and day fields, or an 8-digit string in YYYYMMDD
format. This field is optional. For instance, sitelinkBuilder.withEndDate("20130503");
is equivalent to sitelinkBuilder.withEndDate({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
Arguments:
| Name | Type | Description |
|---|---|---|
|
date
|
Object
|
The new sitelink end date. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
A sitelink builder with the specified end date. |
withFinalUrl(finalUrl)
Sets the final URL of the new sitelink to the specified value. The final URL represents the actual landing page for your sitelink. 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. Final URLs are required.
Arguments:
| Name | Type | Description |
|---|---|---|
|
finalUrl
|
String
|
The final URL for the sitelink. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
The sitelink builder with the specified final URL. |
withFinalUrlSuffix(suffix)
Sets the final URL suffix of the new sitelink to the specified
value. When parallel tracking is enabled, the final URL suffix gets appended to the final URL.
Arguments:
| Name | Type | Description |
|---|---|---|
|
suffix
|
String
|
The final URL suffix to set on the sitelink. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
The sitelink builder with the specified final URL suffix. |
withLinkText(linkText)
Sets the link text of the new sitelink to the specified value. This field
is required. Arguments:
| Name | Type | Description |
|---|---|---|
|
linkText
|
String
|
The link text. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
Sitelink builder with the specified link text. |
withMobileFinalUrl(mobileFinalUrl)
Sets the mobile final URL of the new sitelink to the specified
value. The mobile final URL represents the actual landing page for your sitelink 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:
| Name | Type | Description |
|---|---|---|
|
mobileFinalUrl
|
String
|
The mobile final URL for the sitelink. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
The sitelink builder with the specified final URL. |
withMobilePreferred(isMobilePreferred)
Sets the sitelink's device preference to mobile or clears it.
This field is optional and defaults to withMobilePreferred(isMobilePreferred)
false
.
Arguments:
| Name | Type | Description |
|---|---|---|
|
isMobilePreferred
|
boolean
|
Whether or not this sitelink 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:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
A sitelink builder with the specified mobile preference. |
withSchedules(schedules)
Sets the sitelink scheduling. Scheduling of a sitelink allows you to control the days of week and times of day during which
the sitelink will show alongside your ads. Passing in an empty array clears the scheduling field, causing the sitelink to run at all times.
The following example sets the sitelink 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 }; sitelinkBuilder . withSchedules ([ mondayMorning , tuesdayMorning ]);
Arguments:
| Name | Type | Description |
|---|---|---|
|
schedules
|
AdsApp.ExtensionSchedule[]
|
The new sitelink schedules. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
A sitelink builder with the specified schedules. |
withStartDate(date)
Sets the sitelink's start date from either an object containing
year, month, and day fields, or an 8-digit string in YYYYMMDD
format. This field is optional. For instance, sitelinkBuilder.withStartDate("20130503");
is equivalent to sitelinkBuilder.withStartDate({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 sitelink's end date,
Arguments:
| Name | Type | Description |
|---|---|---|
|
date
|
Object
|
The new sitelink start date. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
A sitelink builder with the specified start date. |
withTrackingTemplate(trackingTemplate)
Sets the tracking template of the new sitelink to the specified
value. You can optionally use the tracking template to specify additional tracking parameters or redirects. Google Ads 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:
| Name | Type | Description |
|---|---|---|
|
trackingTemplate
|
String
|
The tracking template for the sitelink. |
Return values:
| Type | Description |
|---|---|
AdsApp.SitelinkBuilder
|
The sitelink builder with the specified tracking template. |

