Shows how to check whether an ad’s or keyword’s URL is valid. The script checks all ads or all keywords in all accounts the user has access to.
Page Headers
0 | HTTP/1.0 200 OK |
ETag | “AoJ97z39n4WGxoIcUciJ7xgWLjXmIxKf3fB2NSjlkpg=” |
Request-Context | appId=cid-v1:cd765a3e-2aba-43aa-b307-6e4b3b4be342 |
X-Datacenter | eus |
X-Frame-Options | SAMEORIGIN |
x-content-type-options | nosniff |
X-UA-Compatible | IE=edge |
X-XSS-Protection | 1; mode=block |
Strict-Transport-Security | max-age=31536000; includeSubDomains; preload |
X-Rendering-Stack | Dynamic |
Content-Type | text/html |
Cache-Control | public, max-age=558 |
Expires | Mon, 09 Nov 2020 08:58:10 GMT |
Date | Mon, 09 Nov 2020 08:48:52 GMT |
Connection | close |
Akamai-Cache-Status | Hit from child |
report-to | {“group”:”network-errors”,”max_age”:604800,”endpoints”:[{“url”:”https://mdec.nelreports.net/api/report?cat=mdocs”}]} |
nel | {“report_to”:”network-errors”,”max_age”:604800,”success_fraction”:0.01,”failure_fraction”:1.0} |
Keyword Frequency
gt | 114 |
const | 95 |
name | 68 |
quot | 60 |
lt | 57 |
if | 56 |
ad | 45 |
account | 38 |
url | 37 |
function | 36 |
Keyword Cloud
Check for ads or keywords with broken URLs – Microsoft Advertising Docs Skip to main content Contents Exit focus mode Bookmark Feedback Edit Share Twitter LinkedIn Facebook Email Table of contents minutes read In this article This solution shows how check The script performs the on all in accounts that user has access following is high-level flow For more details inline comments Before running set NOTIFY and ENTITY NAME variables Set variable list email addresses you want script’s results sent And specify whether default Reads a file from Google Drive contains objects Each object an account ID time stamp when was last checked first runs shouldn’t exist If doesn’t builds complete Note won’t pick up any new were added after built should delete so it generates Sorts haven’t been are oldest show Gets IDs calls selector’s executeInParallel method executes parallel findBrokenUrls function each returns account’s information URLS if Executes reportResults creates spreadsheet uses Sheets create sheet writes entity Uses Mail send notification specified recipients indicates provides link where they can see Updates lastChecked field saves next sorts by means processed will be need run one times depending number have using example Authenticating services options getting token use Add comma-delimited receive const ‘someone com’ value ‘Ad’ ad ‘Keyword’ keyword Valid values SCRIPT URL Checker ACCOUNTS FILE MicrosoftAds-Scripts-Broken Urls-AccountList json SPREADSHEET PREFIX Urls ACCOUNT BATCH SIZE true get even no found SEND EMAIL EVEN IF NO BROKEN FOUND false include inactive entities INCLUDE INACTIVE ENTITIES custom response checks needed checkResponse url var responseText getContentText includes ‘out stock’ return isGood error ‘Received out stock response’ See page credentials https docs microsoft com en-us advertising scripts examples authenticating-with-google-services chose option Getting accessToken received OAuth playground Otherwise clientId clientSecret refreshToken ” remainingQuota UrlFetchApp getRemainingDailyQuota lt Logger log Remaining fetch quota not enough now it’s JSON id createFileIfNotExists Load empty accountsList loadObject Then add exists since ran To ensure consider deleting periodically length AccountsApp while hasNext push getAccountId lastCheckedId ‘ Sort ensures unprocessed i e sort b gt localeCompare Save back opened again update saveObject Get maximum grabs until eventually processes accountsToCheck slice accountIds map x ‘Checking stringify Use execute When finishes Scripts withIds ‘findBrokenUrls’ ‘reportResults’ FETCH QUOTA EXCEEDED ‘URL exceeded’ BingAdsAccountSelector call selector becomes current instance accountsToCheckJson currentAccount AdsApp currentAccountInfo getName getAccountNumber Processing Contains fields let columns entityName switch case name ‘Campaign’ func getCampaign ‘Campaign Id’ getId ‘AdGroup’ getAdGroup ‘AdGroup getText ‘Keyword ‘Match Type’ getMatchType ‘Final Url’ urls getFinalUrl ‘HTTP code’ ‘checkResult’ code ‘Error’ break ‘Id’ ‘Type’ getType ‘Title’ getHeadline ‘Title isType expandedTextAd asType getHeadlinePart null ‘Text’ getDescription ‘Display getDisplayUrl ‘Destination getDestinationUrl ‘Path getPath executionInfo getExecutionInfo allEntitiesChecked checkedEntitiesCount parse filter entitySelector withCondition Id ‘CampaignStatus ENABLED’ ‘AdGroupStatus ‘Status notCheckedEntities orderBy ‘Id ASC’ totalNumEntities All s else Checking processedEntitiesCountInBatch timeLimitReached urlFetchLimitReached Make sure finish processing ends cleanly getRemainingTime amp try urlCheckResult checkUrlWithCache entityResult reduce temp column catch throw Stopping limit reached Found Create identifies its Convert string that’s past instances customerId getCustomerId accountId accountNumber accountName brokenEntitiesCount brokenEntities rows headers urlCheckCache cachedResult checkResult checkUrl left muteHttpExceptions ‘User-Agent’ ‘Mozilla compatible Microsoft-Ads-Url-Checker message getResponseCode It then sends ‘NOTIFY’ ‘Reporting results’ sheetResults result getReturnValue Got getError continue accountResult sheetName replace removes u character toLocaleString adds date dateTimeStr Date toISOString g spreadsheetName spreadsheetId Adds createSheetsResponse createSheets original accountsById acc sheetsByName updatedSpreadsheet sheets properties title spreadsheetRows summaryEmailData Builds sheetResult sheetRows row rowValues sheetId writeRowsToSpreadsheet sendSummaryEmailIfNeeded Send recipient click embedded about totalbrokenEntitiesCount sum accountData quot Skipping subject Summary fileUrl shareFileWithLink messageHtml html body br table border width style border-collapse collapse tr th align Customer Account Number Name center With Broken Full Report Total Checked td href gid Show Details join toUTCString Completed Subject Content-Type text charset utf- getGmailApi users messages userId ‘me’ raw Base encode Calls getSheetsApi sheetsApi GoogleApis createSheetsService getDriveApi driveApi createDriveService gmailApi createGmailService Creates sheetNames requests addSheet spreadsheets batchUpdate includeSpreadsheetInResponse Writes appendCells columnValue userEnteredValue stringValue toString Returns fileId permissions sign type ‘anyone’ role ‘reader’ allowFileDiscovery fileResponse files ‘webViewLink’ webViewLink findFileId fileName req escape searchResult q isSpreadsheet existingFileId createResult mimeType ‘application vnd google-apps spreadsheet’ document’ obj uploadType ‘simple’ contentType ‘text plain’ Error File fileData export trim Common library createService googleapis discovery rest version v www apis drive gmail Creation logic based developers google usage-simple getAccessToken standardParameters parameters service build ‘rootUrl’ ‘servicePath’ createNewMethod rootUrl servicePath urlParams uploadParams urlPath path supportsMediaUpload Media upload supported uploadProtocols mediaUpload protocols simpleProtocol simple Upload protocol ‘resumable’ resumableProtocol resumable Unknown queryArguments paramConfg Unexpected parameter location ‘path’ ‘query’ ‘media’ startsWith substring payload json’ fetchParams httpMethod Authorization Bearer httpResponse responseContent responseCode parsedResult Response status prototype collection resources resource methods tokenResponse ‘https oauth token’ ‘post’ x-www-form-urlencoded’ client secret refresh grant ‘refresh ‘access github AzureAD microsoft-authentication-library-for-js blob master lib msal-core src Utils ts class static input keyStr ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz output chr enc utf Encode charCodeAt isNaN charAt r n utftext c String fromCharCode Is helpful Yes No Any additional feedback Submit Thank view product View Theme Light Dark High contrast Previous Version Blog Contribute Privacy Cookies Terms Site Trademarks copy