When scripts are executed in preview mode, they make no changes to the actual campaign data. Instead, script execution shows the changes that would have been made had the script been executing. Once satisfied with the output, you can start the live execution of a script or schedule it.
Preview mode is a powerful feature, as it allows you to develop and debug a script without worrying about erroneous changes being made to your Google Ads data.
Preview mode only affects calls that use AdsApp
as an entry point. Calls to
other services will proceed as normal. For example, if a script is using
MailApp
to send an email, it will get sent whether or not the script had been
previewed or executed. Spreadsheets will get updated in both scenarios as
well. A script can find out whether or not it is running in preview mode through
its execution info.
The following snippet will not behave as expected in preview mode:
// Suppose the ad group has no keywords.
let adGroup = findAnEmptyAdGroup();
// Create a keyword.
adGroup.createKeyword("test");
// Fetch all keywords in the ad group.
let keywords = adGroup.keywords().get();
// In preview mode, will log "false": keyword was not actually created.
// In real execution, will log "true".
console.log("Are there keywords in the ad group? " + keywords.hasNext());