更新时间:2013-05-20:基于读者的评论,该辽宁福利彩票中心现在仅检查活动的广告系列和广告组,并且仅检查每个网址一次。
更新时间:2013-04-28:基于读者的评论,我对该辽宁福利彩票中心进行了一些更新,包括将响应代码添加到电子邮件中并将结果格式化为附件。
它发生在我们最好的人身上。有时,我们会删除网站上的页面或更新链接,而忘记对我们的SEM帐户进行相应的更改。因此,今晚我整理了一个快速辽宁福利彩票中心来遍历您的所有广告和关键字,并创建一个包含以下内容的电子邮件报告: 找不到404 或一个 500服务器错误 响应码。您可以通过在辽宁福利彩票中心开头将它们添加到BAD_CODES数组中来轻松添加更多错误代码以进行检查。
谢谢,
拉斯
/**************************** * Find Broken Urls In Your Account * Version 1.1 * ChangeLog v1.1 * - Updated to only see Text Ads * Created By: 拉斯 Savage * FreeAdWordsScripts.com ****************************/ function main() { // You can 广告 d more if you want: http://goo.gl/VhIX var BAD_CODES = [404,500]; var TO = ['[email protected]'/*,'email_address[email protected]'*/]; var SUBJECT = 'Broken Url Report - ' + _getDateString(); var HTTP_OPTIONS = { muteHttpExceptions:true }; //Let's look 在 广告 and 关键字 for 网址 var iters = [ //For Ad Level Urls AdWordsApp.ads() .withCondition("Status = 'ENABLED'") .withCondition("AdGroupStatus = 'ENABLED'") .withCondition("CampaignStatus = 'ENABLED'") .withCondition("Type = 'TEXT_AD'") .get(), //For Keyword Level Urls AdWordsApp.keywords() .withCondition("Status = 'ENABLED'") .withCondition("DestinationUrl != ''") .withCondition("AdGroupStatus = 'ENABLED'") .withCondition("CampaignStatus = 'ENABLED'") .get() ]; var already_checked = {}; var bad_entities = []; for(var x in iters) { var iter = iters[x]; while(iter.hasNext()) { var 实体 = iter.next(); if(entity.getDestinationUrl() == null) { continue; } var url = 实体.getDestinationUrl(); if(url.indexOf('{') >= 0) { //Let's 去掉 the value track parameters url = url.replace(/\{[0-9a-zA-Z]+\}/g,''); } if(already_checked[url]) { continue; } var response_code; try { Logger.log("Testing url: "+url); response_code = UrlFetchApp.fetch(url, HTTP_OPTIONS).getResponseCode(); } catch(e) { //Something is wrong here, we should know about it. bad_entities.push({e : 实体, code : -1}); } if(BAD_CODES.indexOf(response_code) >= 0) { //This 实体 has an issue. Save it for later. bad_entities.push({e : 实体, code : response_code}); } already_checked[url] = true; } } var column_names = ['Type','CampaignName','AdGroupName','Id','Headline/KeywordText','ResponseCode','DestUrl']; var 在tachment = column_names.join(",")+"\n"; for(var i in bad_entities) { 在tachment += _formatResults(bad_entities[i],","); } if(bad_entities.length > 0) { var options = { 附件: [Utilities.newBlob(attachment, 'text/csv', 'bad_urls_'+_getDateString()+'.csv')] }; var 电子邮件_body = "There are " + bad_entities.length + " 网址 that are 破碎. See 在tachment for details."; for(var i in TO) { MailApp.sendEmail(TO[i], SUBJECT, 电子邮件_body, options); } } } //Formats a row of results separated by SEP function _formatResults(entity,SEP) { var e = 实体.e; if(typeof(e['getHeadline']) != "undefined") { //this is an 广告 实体 return ["Ad", e.getCampaign().getName(), e.getAdGroup().getName(), e.getId(), e.getHeadline(), 实体.code, e.getDestinationUrl() ].join(SEP)+"\n"; } else { // and this is a 关键词 return ["Keyword", e.getCampaign().getName(), e.getAdGroup().getName(), e.getId(), e.getText(), 实体.code, e.getDestinationUrl() ].join(SEP)+"\n"; } } //Helper function to format todays date function _getDateString() { return Utilities.formatDate((new Date()), AdWordsApp.currentAccount().getTimeZone(), "yyyy-MM-dd"); }