### getStartDate() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_videocampaign Gets the start date of the video campaign, returned as an object with year, month, and day properties. ```APIDOC ## `getStartDate()` ### Description Returns the campaign's start date. For instance, if a campaign started on May 3, 2013, this would return the following object: `{year: 2013, month: 5, day: 3}`. ### Return values: * Type: `AdsApp.GoogleAdsDate` * Description: The campaign's start date. ``` -------------------------------- ### getStartDate() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_accountsitelink Returns the start date of the account-level sitelink, or null if no start date is set. ```APIDOC ## getStartDate() ### Description Returns the start date of the account-level sitelink, or `null` if no start date is set. For instance, if the start date of the account-level sitelink is May 3, 2013, this would return the following object: `{year: 2013, month: 5, day: 3}`. ### Return values: Type| Description ---|--- `AdsApp.GoogleAdsDate` | The account-level sitelink's start date, or `null` if there's no start date. ``` -------------------------------- ### startApplying() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_experiment Starts applying the experiment's changes back to the base campaign. This operation does not wait for completion. Users can monitor the progress in the UI's All experiments tab. ```APIDOC ## `startApplying()` ### Description Starts applying the experiment's changes back to the base campaign. This method does not wait for the process to complete. You can monitor the status in the **All experiments** tab of the UI. ### Returns Nothing. ``` -------------------------------- ### Get Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_campaigncallout Retrieves the start date of the campaign-level callout. Returns null if no start date is set. ```javascript var startDate = campaignCallout.getStartDate(); ``` -------------------------------- ### Get Campaign Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_campaign Retrieves the campaign's start date. ```javascript var startDate = campaign.getStartDate(); ``` -------------------------------- ### Initialize and Populate Spreadsheet Source: https://developers.google.com/google-ads/scripts/docs/solutions/ad-performance Sets up the spreadsheet by adding headers and account ID. It then calls outputSegmentation to populate data for headlines and final URLs. ```javascript const headlineSheet = spreadsheet.getSheetByName('Headline'); headlineSheet.getRange(1, 2, 1, 1).setValue('Date'); headlineSheet.getRange(1, 3, 1, 1).setValue(new Date()); const finalUrlSheet = spreadsheet.getSheetByName('Final Url'); finalUrlSheet.getRange(1, 2, 1, 1).setValue('Date'); finalUrlSheet.getRange(1, 3, 1, 1).setValue(new Date()); spreadsheet.getRangeByName('account_id_headline').setValue( AdsApp.currentAccount().getCustomerId()); spreadsheet.getRangeByName('account_id_final_url').setValue( AdsApp.currentAccount().getCustomerId()); // Only include ad types on the headline sheet for which the concept of a // headline makes sense. outputSegmentation(headlineSheet, 'Headline', (adGroupAd) => { switch (adGroupAd.ad.type) { case 'TEXT_AD': return adGroupAd.ad.textAd.headline; case 'EXPANDED_TEXT_AD': return adGroupAd.ad.expandedTextAd.headlinePart1 + ' - ' + adGroupAd.ad.expandedTextAd.headlinePart2; case 'RESPONSIVE_DISPLAY_AD': return adGroupAd.ad.responsiveDisplayAd.longHeadline.text; case 'VIDEO_RESPONSIVE_AD': return adGroupAd.ad.videoResponsiveAd.longHeadlines.map( asset => asset.text); case 'RESPONSIVE_SEARCH_AD': return adGroupAd.ad.responsiveSearchAd.headlines.map( asset => asset.text); case 'APP_ENGAGEMENT_AD': return adGroupAd.ad.appEngagementAd.headlines.map(asset => asset.text); case 'APP_AD': return adGroupAd.ad.appAd.headlines.map(asset => asset.text); case 'CALL_AD': return adGroupAd.ad.callAd.headline1 + ' - ' + adGroupAd.ad.callAd.headline2; case 'LEGACY_RESPONSIVE_DISPLAY_AD': return adGroupAd.ad.legacyResponsiveDisplayAd.longHeadline; case 'LOCAL_AD': return adGroupAd.ad.localAd.headlines.map(asset => asset.text); case 'SHOPPING_COMPARISON_LISTING_AD': return adGroupAd.ad.shoppingComparisonListingAd.headline; case 'SMART_CAMPAIGN_AD': return adGroupAd.ad.smartCampaignAd.headlines.map(asset => asset.text); case 'VIDEO_AD': return adGroupAd.ad.videoAd.inFeed.headline; case 'DISCOVERY_CAROUSEL_AD': return adGroupAd.ad.discoveryCarouselAd.headline.text; case 'DISCOVERY_MULTI_ASSET_AD': return adGroupAd.ad.discoveryMultiAssetAd.headlines.map(asset => asset.text); default: return; } }); outputSegmentation( finalUrlSheet, 'Final Url', (adGroupAd) => adGroupAd.ad.finalUrls); console.log(`Ad performance report available at\n${spreadsheet.getUrl()}`); validateEmailAddresses(RECIPIENT_EMAILS); MailApp.sendEmail( RECIPIENT_EMAILS.join(','), 'Ad Performance Report is ready', spreadsheet.getUrl()); ``` -------------------------------- ### getStartDate() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_campaignsitelink Returns the start date of the campaign-level sitelink, or null if no start date is set. ```APIDOC ## `getStartDate()` ### Description Returns the start date of the campaign-level sitelink, or `null` if no start date is set. ### Return values: * `AdsApp.GoogleAdsDate` - The campaign-level sitelink's start date, or `null` if there's no start date. ``` -------------------------------- ### build Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_responsivedisplayadbuilder Builds and returns the ResponsiveDisplayAd. ```APIDOC ## build() ### Description Builds and returns the ResponsiveDisplayAd. ### Method build ### Return values * ResponsiveDisplayAd - The created ResponsiveDisplayAd. ``` -------------------------------- ### Get Campaign Price Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_campaignprice Retrieves the start date of a campaign-level price. Returns null if no start date is set. ```javascript var startDate = campaignPrice.getStartDate(); ``` -------------------------------- ### startApplying() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_draft Initiates the process of applying the draft's changes back to the base campaign. This operation is asynchronous. ```APIDOC ## `startApplying()` ### Description Starts applying the draft's changes back to the base campaign. Does not wait for completion. View this draft in the "All drafts" tab of the UI to see if its changes are finished being applied. ### Returns Nothing. ``` -------------------------------- ### Get Campaign Sitelink Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_campaignsitelink Retrieves the start date of a campaign-level sitelink. Returns null if no start date is set. ```javascript var startDate = campaignSitelink.getStartDate(); ``` -------------------------------- ### ExperimentBuilder.startBuilding() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_experimentbuilder Initiates the experiment building process. This method returns nothing and the experiment creation is tracked in the UI. ```APIDOC ## `startBuilding()` ### Description Initiates the experiment building process. Unlike calls to `Builder.build()`, this method returns nothing. Navigate to the **All experiments** tab of the UI to track the new experiment's creation. ### Return values: Returns nothing. ``` -------------------------------- ### Get account-level price start date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_accountprice Retrieves the start date of an account-level price. Returns null if no start date is set. ```javascript var startDate = accountPrice.getStartDate(); ``` -------------------------------- ### getStartDate() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_accountcallout Retrieves the start date of the account-level callout. Returns null if no start date is set. The date is returned as an object with year, month, and day properties. ```APIDOC ## getStartDate() ### Description Returns the start date of the account-level callout, or `null` if no start date is set. ### Return values: Type| Description ---|--- `AdsApp.GoogleAdsDate` | The account-level callout's start date, or `null` if there's no start date. ``` -------------------------------- ### Get Account Sitelink Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_accountsitelink Retrieves the start date of an account-level sitelink. Returns null if no start date is set. ```javascript var startDate = accountSitelink.getStartDate(); ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_responsivevideoadbuilder Creates a responsive video ad. Returns a VideoAdOperation that can be used to get the new ad or access any associated errors if creation failed. ```APIDOC ## build() ### Description Creates a responsive video ad. Returns a `VideoAdOperation` that can be used to get the new ad (or access any associated errors if creation failed). ### Return values: - `AdsApp.VideoAdOperation`: The associated ad operation. ``` -------------------------------- ### Get Account Snippet Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_accountsnippet Retrieves the start date configured for the account-level snippet. Returns null if no start date is set. ```javascript var startDate = AdsApp.accountSnippets().getStartDate(); if (startDate) { Logger.log("Start date is: %s/%s/%s", startDate.month, startDate.day, startDate.year); } else { Logger.log("No start date is set."); } ``` -------------------------------- ### Zip and Unzip Files Source: https://developers.google.com/google-ads/scripts/docs/examples/miscellaneous This example shows how to use the Utilities.zip and Utilities.unzip functions to create a zip archive from multiple blobs and then extract the contents of a zip archive. It fetches two image files to demonstrate the zipping process. ```javascript function zipUnzip() { const googleFavIconUrl = 'https://www.google.com/favicon.ico'; const googleLogoUrl = 'https://www.google.com/images/srpr/logo3w.png'; // Fetch the Google favicon.ico file and get the Blob data. const faviconBlob = UrlFetchApp.fetch(googleFavIconUrl).getBlob(); const logoBlob = UrlFetchApp.fetch(googleLogoUrl).getBlob(); // zip now references a blob containing an archive of both faviconBlob and // logoBlob. const zip = Utilities.zip([faviconBlob, logoBlob], 'google_images.zip'); // This will now unzip the blobs. const files = Utilities.unzip(zip); } ``` -------------------------------- ### getStartDate() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_accountprice Retrieves the start date for the account's pricing configuration. ```APIDOC ## getStartDate() ### Description Retrieves the start date for the account's pricing configuration. ### Return values * Returns the start date of the pricing configuration. ``` -------------------------------- ### Get Shopping Campaign Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_shoppingcampaign Retrieves the start date of the shopping campaign as a GoogleAdsDate object. ```javascript var startDate = shoppingCampaign.getStartDate(); ``` -------------------------------- ### getStartDate() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_snippet Retrieves the start date of the snippet. Returns null if no start date is set. The date is returned as an object with year, month, and day properties. ```APIDOC ## getStartDate() ### Description Returns the start date of the snippet, or `null` if no start date is set. For instance, if the start date of the snippet is May 3, 2013, this would return the following object: `{year: 2013, month: 5, day: 3}`. ### Return values: Type| Description ---|--- `AdsApp.GoogleAdsDate` | The snippet's start date, or `null` if there's no start date. ``` -------------------------------- ### Filtering by Sitelink Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_sitelinkselector Example of filtering sitelinks by their start date using the equality operator. ```javascript withCondition("asset.sitelink_asset.start_date = '2022-12-25'") ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_bumperadbuilder Creates a bumper video ad. Returns a VideoAdOperation that can be used to get the new ad or access any associated errors if creation failed. ```APIDOC ## `build()` Creates a bumper video ad. Returns a `VideoAdOperation` that can be used to get the new ad (or access any associated errors if creation failed). ### Return values: Type| Description ---|--- `AdsApp.VideoAdOperation` | The associated ad operation. ``` -------------------------------- ### Get AdGroupCallout Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_adgroupcallout Retrieves the start date for an AdGroupCallout. Returns null if no start date is set. The date is returned as an object with year, month, and day properties. ```javascript var startDate = adGroupCallout.getStartDate(); ``` -------------------------------- ### Get Sitelink Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_sitelink Retrieves the start date of the sitelink. If no start date is set, this method returns null. The date is returned as an object with year, month, and day properties. ```javascript var startDate = sitelink.getStartDate(); if (startDate) { Logger.log("Sitelink starts on: %d/%d/%d", startDate.month, startDate.day, startDate.year); } ``` -------------------------------- ### Create a Campaign Budget Source: https://developers.google.com/google-ads/scripts/docs/concepts/mutate Demonstrates how to create a new campaign budget using the `create` operation within `campaignBudgetOperation`. ```javascript const budgetResult = AdsApp.mutate({ campaignBudgetOperation: { create: { amountMicros: 10000000, explicitlyShared: false } } }); ``` -------------------------------- ### Get Ad Group Sitelink Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_adgroupsitelink Retrieves the start date of an ad group-level sitelink. Returns null if no start date is set. The date is returned as an AdsApp.GoogleAdsDate object. ```javascript var startDate = adGroupSitelink.getStartDate(); ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_responsivesearchadbuilder Builds and creates the responsive search ad. ```APIDOC ## build() ### Description Builds and creates the responsive search ad. ### Return values: * [Returns nothing] ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_productadbuilder Creates a ProductAd. Returns a ProductAdOperation that can be used to get the new product ad or access any associated errors if creation failed. ```APIDOC ## build() ### Description Creates a ProductAd. Returns a `ProductAdOperation` that can be used to get the new product ad (or access any associated errors if creation failed). ### Return values: * Type: `AdsApp.ProductAdOperation` Description: The associated product ad operation. ``` -------------------------------- ### Get Start Minute of Ad Schedule Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_adschedule Retrieves the starting minute of an ad schedule. Only returns 0, 15, 30, or 45. ```javascript var startMinute = adSchedule.getStartMinute(); ``` -------------------------------- ### Get Phone Number Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_phonenumber Retrieves the start date of a phone number. Returns null if no start date is set. The date is returned as an object with year, month, and day properties. ```javascript var startDate = phoneNumber.getStartDate(); if (startDate) { Logger.log("Start date: %s/%s/%s", startDate.month, startDate.day, startDate.year); } ``` -------------------------------- ### build Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_responsivedisplayadbuilder Creates a responsive ad for Display. This method finalizes the ad creation process and returns an AdOperation. ```APIDOC ## `build()` ### Description Creates a responsive ad for Display. Returns an `AdOperation` that can be used to get the new ad (or access any associated errors if creation failed). ### Return values * `AdsApp.AdOperation` - The associated ad operation. ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_videotopicbuilder Builds the video topic. Returns a VideoTopicOperation that corresponds to the creation of the VideoTopic. ```APIDOC ## build() ### Description Builds the video topic. Returns a VideoTopicOperation that corresponds to the creation of the VideoTopic. ### Return values: * `AdsApp.VideoTopicOperation` - The VideoTopicOperation. ``` -------------------------------- ### Get Mobile App Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_mobileapp Retrieves the start date of a mobile app. Returns null if no start date is set. The date is returned as an object with year, month, and day properties. ```javascript var startDate = mobileApp.getStartDate(); if (startDate) { Logger.log("App started on %d/%d/%d", startDate.month, startDate.day, startDate.year); } ``` -------------------------------- ### Get Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_adgroupphonenumber Retrieves the start date of the ad group-level phone number. Returns null if no start date is set. The date is returned as an object with year, month, and day properties. ```javascript var startDate = adGroupPhoneNumber.getStartDate(); // Example: {year: 2013, month: 5, day: 3} ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_videoyoutubechannelbuilder Builds the video YouTube channel. Returns a VideoYouTubeChannelOperation that corresponds to the creation of the VideoYouTubeChannel. ```APIDOC ## build() ### Description Builds the video YouTube channel. Returns a VideoYouTubeChannelOperation that corresponds to the creation of the VideoYouTubeChannel. ### Return values: * `AdsApp.VideoYouTubeChannelOperation` - The VideoYouTubeChannelOperation. ``` -------------------------------- ### withStartDate(date) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_experimentbuilder Sets the experiment's start date. The date can be provided as an object with year, month, and day fields, or as an 8-digit string in YYYYMMDD format. This field is optional and defaults to the base campaign's start date if not specified. ```APIDOC ## `withStartDate(date)` ### Description Sets the experiment'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 and will default to the start date of the base campaign if not specified. ### Arguments * **date** (`Object` or `String`) - Required - Experiment start date. Accepts an object with `year`, `month`, `day` fields or an 8-digit string in `YYYYMMDD` format. ### Return values * **`AdsApp.ExperimentBuilder`** - Experiment builder with the specified start date. ``` -------------------------------- ### Get Performance Max Campaign Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_performancemaxcampaign Retrieves the start date of a Performance Max campaign. The date is returned as a GoogleAdsDate object. ```javascript var startDate = performanceMaxCampaign.getStartDate(); ``` -------------------------------- ### withStartDate Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_sitelinkbuilder Sets the start date for the sitelink. ```APIDOC ## withStartDate(date) ### Description Sets the start date for the sitelink. ### Method Not applicable (SDK method) ### Endpoint Not applicable (SDK method) ### Parameters #### Arguments * **date** - Required - The start date for the sitelink. ``` -------------------------------- ### Get Video Campaign Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_videocampaign Retrieves the start date of a video campaign. The returned object contains year, month, and day properties. ```javascript var startDate = videoCampaign.getStartDate(); ``` -------------------------------- ### Build a product ad Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_productadbuilder Typical usage for building a product ad. Calling build() is sufficient to create the ad, but getResult() can be used to access the ad for further processing. ```javascript var adOperation = shoppingAdGroup.newAdBuilder().build(); var ad = adOperation.getResult(); ``` -------------------------------- ### Get account-level mobile app start date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_accountmobileapp Retrieves the start date of an account-level mobile app. Returns null if no start date is set. The date is returned as an object with year, month, and day properties. ```javascript var startDate = accountMobileApp.getStartDate(); if (startDate) { Logger.log('Start date: %d/%d/%d', startDate.month, startDate.day, startDate.year); ``` -------------------------------- ### enable() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_videocampaign Enables the video campaign. ```APIDOC ## `enable()` ### Description Enables the video campaign. ### Return values: Returns nothing. ``` -------------------------------- ### Get Account Phone Number Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_accountphonenumber Retrieves the start date of the account-level phone number. Returns null if no start date is set. The date is returned as an object with year, month, and day properties. ```javascript var startDate = accountPhoneNumber.getStartDate(); ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_infeedadbuilder Creates an in-feed video ad. Returns a VideoAdOperation that can be used to get the new ad or access any associated errors if creation failed. ```APIDOC ## `build()` ### Description Creates an in-feed video ad. Returns a `VideoAdOperation` that can be used to get the new ad (or access any associated errors if creation failed). ### Return values: - `AdsApp.VideoAdOperation`: The associated ad operation. ``` -------------------------------- ### Get Start Hour of Ad Schedule Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_adschedule Retrieves the starting hour of an ad schedule based on a 24-hour clock. Valid hours range from 0 to 23. ```javascript var startHour = adSchedule.getStartHour(); ``` -------------------------------- ### Get Ad Group Mobile App Start Date Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_adgroupmobileapp Retrieves the start date of an ad group-level mobile app. Returns null if no start date is set. The date is returned as an object with year, month, and day properties. ```javascript var startDate = adGroupMobileApp.getStartDate(); if (startDate) { Logger.log("Start date: %d/%d/%d", startDate.month, startDate.day, startDate.year); } ``` -------------------------------- ### setStartDate(date) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_accountprice Sets the start date for the account's pricing configuration. ```APIDOC ## setStartDate(date) ### Description Sets the start date for the account's pricing configuration. ### Arguments * **date**: The start date to set. ``` -------------------------------- ### Example: Filter by Keyword Text using Regex Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_displaykeywordselector Filters display keywords by matching their text using a regular expression. This example matches keywords starting with 'leather'. ```javascript withCondition("ad_group_criterion.keyword.text REGEXP_MATCH 'leather.*'") ``` -------------------------------- ### Create a Shopping Product Group Hierarchy Source: https://developers.google.com/google-ads/scripts/docs/examples/shopping This example demonstrates how to build a product group hierarchy for a shopping ad group. It includes creating brand and condition-based product groups. ```javascript function createElectronicsProductGroups() { // This example snippet assumes a user has a shopping campaign named // 'Shopping' that includes an ad group named 'Electronics'. Please customize // the product group hierarchy to suit your use case. const shoppingCampaignName = 'Shopping'; const shoppingAdGroupName = 'Electronics'; const shoppingAdGroup = AdsApp.shoppingAdGroups() .withCondition(`campaign.name = "${shoppingCampaignName}"`) .withCondition(`ad_group.name = "${shoppingAdGroupName}"`) .get() .next(); const rootProductGroup = shoppingAdGroup.rootProductGroup(); // The created product group hierarchy will be // - root // - 'Cardcow' brand // - New condition // - Refurbished condition // - Other conditions // - Other brands // Add a brand product group for 'Cardcow' under the root product group. const brandNode = rootProductGroup.newChild() .brandBuilder() .withName('Cardcow') .withBid(1.2) .build() .getResult(); // Add groups for new and refurbished Cardcow brand items. const newItems = brandNode.newChild() .conditionBuilder() .withCondition('NEW') .build() .getResult(); const refurbishedItems = brandNode.newChild() .conditionBuilder() .withCondition('REFURBISHED') .withBid(0.9) .build() .getResult(); } ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_videoplacementbuilder Builds the video placement. Returns a VideoPlacementOperation that corresponds to the creation of the VideoPlacement. ```APIDOC ## build() ### Description Builds the video placement. Returns a VideoPlacementOperation that corresponds to the creation of the VideoPlacement. ### Return values: * `AdsApp.VideoPlacementOperation` - The VideoPlacementOperation. ``` -------------------------------- ### Get Campaign Selector Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp Retrieves a selector for all search and display campaigns in the account. This is the starting point for managing campaigns via scripts. ```javascript var campaignSelector = AdsApp.campaigns(); ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_nonskippableadbuilder Creates the non-skippable ad. ```APIDOC ## build() ### Description Creates the non-skippable ad. ### Method Not applicable (this is a builder method). ### Endpoint Not applicable. ### Parameters None. ### Request Example None. ### Response #### Success Response Returns the newly created non-skippable ad object. ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_imageadbuilder Creates an image ad and returns an AdOperation to manage the new ad or its errors. ```APIDOC ## `build()` ### Description Creates an image ad. Returns an `AdOperation` that can be used to get the new ad (or access any associated errors if creation failed). ### Return values: * `AdsApp.AdOperation`: The associated ad operation. ``` -------------------------------- ### Get excluded audiences for an ad group Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_searchadgroupexcludedaudienceselector Retrieves an iterator for excluded audiences associated with an ad group. This is the typical way to start fetching excluded audience data. ```javascript var adGroup = AdsApp.adGroups().get().next(); var excludedAudienceSelector = adGroup.targeting().excludedAudiences(); var excludedAudienceIterator = excludedAudienceSelector.get(); while (excludedAudienceIterator.hasNext()) { var excludedAudience = excludedAudienceIterator.next(); } ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_displaykeywordbuilder Builds the display keyword. Returns a DisplayKeywordOperation that corresponds to the creation of the DisplayKeyword. ```APIDOC ## build() ### Description Builds the display keyword. Returns a DisplayKeywordOperation that corresponds to the creation of the DisplayKeyword. ### Return values: * `AdsApp.DisplayKeywordOperation` - The DisplayKeywordOperation. ``` -------------------------------- ### Fetch Excluded Video YouTube Videos Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_excludedvideoyoutubevideoselector Use `get()` to retrieve an iterator for all excluded video YouTube videos. This is the primary method to start selecting excluded videos. ```javascript var iterator = AdsApp.excludedVideoYouTubeVideos().get(); ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_videokeywordbuilder Builds the video keyword. Returns a VideoKeywordOperation that corresponds to the creation of the VideoKeyword. ```APIDOC ## build() ### Description Builds the video keyword. Returns a VideoKeywordOperation that corresponds to the creation of the VideoKeyword. ### Return values: * `AdsApp.VideoKeywordOperation` - The VideoKeywordOperation. ``` -------------------------------- ### Validate and Get Spreadsheet Source: https://developers.google.com/google-ads/scripts/docs/solutions/account-summary Validates the spreadsheet URL and checks for a valid email configuration. Throws errors if the URL is a placeholder or if the email is set to the default example address. ```javascript /** * Validates the provided spreadsheet URL to make sure that it's set up * properly. Throws a descriptive error message if validation fails. * * @return {!Spreadsheet} The spreadsheet object itself, fetched from the URL. */ function validateAndGetSpreadsheet() { if ('YOUR_SPREADSHEET_URL' == SPREADSHEET_URL) { throw new Error('Please specify a valid Spreadsheet URL. You can find' + ' a link to a template in the associated guide for this script.'); } const spreadsheet = SpreadsheetApp.openByUrl(SPREADSHEET_URL); const email = spreadsheet.getRangeByName('email').getValue(); if ('foo@example.com' == email) { throw new Error('Please either set a custom email address in the' ' spreadsheet, or set the email field in the spreadsheet to blank' ' to send no email.'); } return spreadsheet; } ``` -------------------------------- ### Filter negative keywords by text and match type Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_negativekeywordselector Shows how to apply multiple conditions to a negative keyword selector. This example retrieves negative keywords that start with 'a' and are of the broad match type. ```javascript var selector = AdsApp.negativeKeywords(); var filteredSelector = selector .withCondition("ad_group_criterion.keyword.text REGEXP_MATCH 'a.*'") .withCondition("ad_group_criterion.keyword.match_type = BROAD"); ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_instreamadbuilder Creates an in-stream video ad. Returns a VideoAdOperation that can be used to get the new ad or access any associated errors if creation failed. ```APIDOC ## build() ### Description Creates an in-stream video ad. Returns a `VideoAdOperation` that can be used to get the new ad (or access any associated errors if creation failed). ### Return values: - `AdsApp.VideoAdOperation`: The associated ad operation. ``` -------------------------------- ### startScheduling() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_experiment Schedules the experiment according to the set start date, materializing in-design campaigns to experiment campaigns. This requires changes to be made to the in-design campaigns beforehand. The operation does not wait for completion. Users can verify successful scheduling in the UI's All experiments tab. ```APIDOC ## `startScheduling()` ### Description Schedules the experiment based on the configured start date. This action materializes the virtual in-design campaigns into experiment campaigns. It is a prerequisite that some changes have been made to the in-design campaigns before scheduling can occur. This method does not wait for the scheduling process to finish. You can check the status of the scheduling in the **All experiments** tab of the UI. ### Returns Nothing. ``` -------------------------------- ### Retrieve Performance Max Campaign Statistics Source: https://developers.google.com/google-ads/scripts/docs/examples/performance-max Get statistics for a Performance Max campaign, such as clicks, impressions, and cost, for a specified date range. This example retrieves stats for the last month. ```javascript function main() { var campaignName = "My Performance Max Campaign"; var performanceMaxCampaign = AdsApp.performanceMaxCampaigns() .withCondition("Name = '" + campaignName + "'") .get() .next(); if (performanceMaxCampaign) { var stats = performanceMaxCampaign.getStatsFor("LAST_MONTH"); Logger.log( 'Stats for Performance Max campaign \'%s\':\nClicks: %s\nImpressions: %s\nCost: %s\n', performanceMaxCampaign.name(), stats.clicks, stats.impressions, stats.cost); } else { Logger.log('Performance Max campaign with name \'%s\' not found.\n', campaignName); } } ``` -------------------------------- ### Get Stats for Custom Date Range (Object) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_productchannelexclusivity Fetches statistics for a custom date range using objects with year, month, and day properties for start and end dates. The range is inclusive. ```javascript var stats = productChannelExclusivity.getStatsFor({year: 2023, month: 1, day: 1}, {year: 2023, month: 1, day: 31}); ``` -------------------------------- ### Create a Video Placement Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_videoplacementbuilder Use this snippet to create a standard video placement. The withUrl() method is required and must be called before build(). ```javascript var videoPlacementBuilder = videoAdGroup .videoTargeting() .newPlacementBuilder(); var videoPlacementOperation = videoPlacementBuilder .withUrl('"http://www.site.com"') // required .build(); // create the placement ``` -------------------------------- ### Get Stats for a Custom Date Range (String) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_campaignphonenumber Retrieves statistics for a campaign-level phone number using custom start and end dates provided as YYYYMMDD strings. The date range is inclusive. ```javascript var stats = campaignPhoneNumber.getStatsFor("20130324", "20130324"); ``` -------------------------------- ### Get Audience Stats for a Custom Date Range (String Input) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_audience Retrieves performance statistics using custom start and end dates provided as 'YYYYMMDD' strings. The date range is inclusive. ```javascript var stats = audience.getStatsFor("20230101", "20230131"); ``` -------------------------------- ### Accessing Campaign Extensions Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_campaignextensions This example demonstrates how to access all sitelinks belonging to a campaign. ```APIDOC ## Accessing Campaign Extensions ### Description This example demonstrates how to access all sitelinks belonging to a campaign. ### Code Example ```javascript var campaignSitelinkIterator = campaign.extensions().sitelinks().get(); while (campaignSitelinkIterator.hasNext()) { var campaignSitelink = campaignSitelinkIterator.next(); } ``` ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_placementbuilder Builds the placement. Returns a PlacementOperation that corresponds to the creation of the Placement. ```APIDOC ## build() ### Description Builds the placement. Returns a PlacementOperation that corresponds to the creation of the Placement. ### Return values: - `AdsApp.PlacementOperation`: The PlacementOperation. ``` -------------------------------- ### Filter by campaign status and name pattern Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_searchcampaignexcludedaudienceselector Adds conditions to narrow down the results. Multiple conditions are AND-ed together. This example retrieves excluded audiences from ENABLED campaigns whose names start with 'a'. ```javascript var selector = AdsApp.searchCampaignExcludedAudiences(); selector = selector .withCondition("campaign.status = 'ENABLED'") .withCondition("campaign.name REGEXP_MATCH 'a.*'"); ``` -------------------------------- ### Get Stats for a Custom Date Range (String) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_productitemid Retrieves performance statistics for a product item ID using a custom date range specified by start and end dates in 'YYYYMMDD' string format. ```javascript var stats = productItemId.getStatsFor("20230324", "20230324"); ``` -------------------------------- ### Create a Sitelink Extension Source: https://developers.google.com/google-ads/scripts/docs/examples/sitelinks Demonstrates how to build a new sitelink extension with text, URL, and mobile preference. It then shows how to add this sitelink to a specific campaign, ad group, or at the account level. Replace placeholder values with your actual campaign and ad group names. ```javascript function createSitelink() { // For full details on creating a new sitelink extension, see: // https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_sitelinkbuilder const newSitelink = AdsApp.extensions().newSitelinkBuilder() // Replace the values below with your link link text, final url, and // mobile preferred .withLinkText('Music') // required .withFinalUrl('http://www.example.com/Music') // required .withMobilePreferred(true) // optional .build() .getResult(); // Add sitelink to a campaign const campaignIterator = AdsApp.campaigns() .withCondition('campaign.name = "INSERT_CAMPAIGN_NAME_HERE"') .get(); if (campaignIterator.hasNext()) { const campaign = campaignIterator.next(); campaign.addSitelink(newSitelink); } // Add sitelink to an ad group const adGroupIterator = AdsApp.adGroups() .withCondition('campaign.name = "INSERT_CAMPAIGN_NAME_HERE"') .withCondition('ad_group.name = "INSERT_AD_GROUP_NAME_HERE"') .get(); if (adGroupIterator.hasNext()) { const adGroup = adGroupIterator.next(); adGroup.addSitelink(newSitelink); } // Add sitelink to an account const account = AdsApp.currentAccount(); account.addSitelink(newSitelink); } ``` -------------------------------- ### Get Stats for Date Range (Custom) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_imagead Retrieves statistics for a custom date range specified by start and end dates. Dates can be provided as YYYYMMDD strings or objects with year, month, and day properties. ```javascript var stats = ad.getStatsFor("20130324", "20130324"); ``` ```javascript var stats = ad.getStatsFor({year: 2013, month: 3, day: 24}, {year: 2013, month: 3, day: 24}); ``` -------------------------------- ### withStartDate Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder Sets the price'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. ```APIDOC ## `withStartDate(date)` ### Description Sets the price'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. The change will fail and report an error if the given date is invalid or if it is after the price's end date. ### Arguments: Name| Type| Description ---|---|--- `date` | `Object` | The new price start date. ### Return values: Type| Description ---|--- `AdsApp.PriceBuilder` | A price builder with the specified start date. ``` -------------------------------- ### Get Campaign Price Stats for Custom Date Range (String) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_campaignprice Fetches performance statistics for a campaign-level price using a custom date range specified by start and end date strings in YYYYMMDD format. ```javascript var stats = campaignPrice.getStatsFor("20130324", "20130324"); ``` -------------------------------- ### build() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_videomobileapplicationbuilder Builds the video mobile application. Returns a VideoMobileApplicationOperation that corresponds to the creation of the VideoMobileApplication. ```APIDOC ## build() ### Description Builds the video mobile application. Returns a VideoMobileApplicationOperation that corresponds to the creation of the VideoMobileApplication. ### Return values: * `AdsApp.VideoMobileApplicationOperation` - The VideoMobileApplicationOperation. ``` -------------------------------- ### getStartDate() Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_campaignprice Returns the start date of the campaign price. ```APIDOC ## getStartDate() ### Description Returns the start date of the campaign price. ### Method Not applicable (SDK method) ### Return values * **string** - The start date in YYYY-MM-DD format. ``` -------------------------------- ### Get Stats for a Custom Date Range (Object) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_campaignphonenumber Retrieves statistics for a campaign-level phone number using custom start and end dates provided as objects with year, month, and day properties. The date range is inclusive. ```javascript var stats = campaignPhoneNumber.getStatsFor({year: 2013, month: 3, day: 24}, {year: 2013, month: 3, day: 24}); ``` -------------------------------- ### Get Stats for Custom Date Range (Object) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_callout Retrieves statistics for a callout using a custom date range defined by start and end date objects. Each date object should contain year, month, and day properties. ```javascript var stats = callout.getStatsFor({year: 2013, month: 3, day: 24}, {year: 2013, month: 3, day: 24}); ``` -------------------------------- ### Create a Video Topic Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_videotopicbuilder Use this snippet to create a new video topic by specifying the topic ID and then calling build(). ```javascript var videoTopicBuilder = videoAdGroup.videoTargeting().newTopicBuilder(); var videoTopicOperation = videoTopicBuilder .withTopicId(3) // required .build(); // create the topic ``` -------------------------------- ### Get Audience Stats for a Custom Date Range (Object Input) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_audience Retrieves performance statistics using custom start and end dates provided as objects with year, month, and day properties. The date range is inclusive. ```javascript var stats = audience.getStatsFor({year: 2023, month: 1, day: 1}, {year: 2023, month: 1, day: 31}); ``` -------------------------------- ### withStartDate(date) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder Sets the start date for the price builder. This method defines when the pricing collection becomes active. ```APIDOC ## withStartDate(date) ### Description Sets the start date for the price builder. This method defines when the pricing collection becomes active. ### Method Not applicable (SDK method) ### Parameters #### Arguments * **date** - The start date for the price builder. ``` -------------------------------- ### Get Video Mobile Application Stats for a Custom Date Range (String) Source: https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_videomobileapplication Fetches statistics for a video mobile application using custom start and end dates provided as strings in 'YYYYMMDD' format. The date range is inclusive. ```javascript var stats = mobileApplication.getStatsFor("20130324", "20130324"); ```