Stay organized with collections
Save and categorize content based on your preferences.
AI-generated Key Takeaways
This page documents the SnippetBuilder object, which is used to create Snippet extension objects in Google Ads scripts.
SnippetBuilder provides methods like withHeader, withValues, withStartDate, withEndDate, withSchedules, and withMobilePreferred to set snippet properties.
The build method creates a SnippetOperation to obtain the new Snippet object or handle potential errors.
Refer to the detailed documentation of each method for specific usage instructions and argument details.
Several methods within the SnippetBuilder object have been deprecated.
Creates a Snippet.
Returns a SnippetOperation
that can be used to get the new snippet (or access any
associated errors if creation failed).
Defaults to building the type of snippet that is currently
serving. If there are upgraded snippets, then an upgraded
snippet will be built by default. If there are only legacy
snippets, then a legacy snippet will be built
by default. If there are neither, then an upgraded snippet will
be built by default.
Arguments:
Name
Type
Description
buildLegacy
boolean
If true, builds a legacy snippet. If false, builds an upgraded snippet. If
unspecified, defaults to building whichever type is currently serving.
Sets the snippet'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, snippetBuilder.withEndDate("20130503"); is equivalent to snippetBuilder.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}),
Sets the snippet's device preference to mobile or clears it.
This field is optional and defaults to false.
Arguments:
Name
Type
Description
isMobilePreferred
boolean
Whether or not this snippet 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.
A snippet builder with the specified mobile preference.
withSchedules(schedules)
Sets the snippet scheduling. Scheduling of a snippet allows you to control the days of week and times of day during which
the snippet will show alongside your ads.
Passing in an empty array clears the scheduling field, causing the snippet to run at all times.
The following example sets the snippet to run on Mondays and
Tuesday from 8:00 to 11:00.
Sets the snippet'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, snippetBuilder.withStartDate("20130503"); is equivalent to snippetBuilder.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}),
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-23 UTC."],[],[]]