Adwords死链接自动检查脚本

作者: zenglihunter 分类: Adwords 发布时间: 2013-10-23 17:18 ė14,644 Views 6没有评论

这个死链接自动检查脚本是用来检查adwords账户哪些广告链接出现了错误的,可以定期执行将死链接报表发送到指定的邮箱中^_^

function main() {
var BAD_CODES = [404,500];

// 替换成自己的邮箱地址
  var TO = [‘email@example.com‘];
var SUBJECT = ‘Broken Url Report - ‘ + _getDateString();
var HTTP_OPTIONS = {
muteHttpExceptions:true
};
//Let’s look at ads and keywords for urls
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 entity = iter.next();
if(entity.getDestinationUrl() == null) { continue; }
var url = entity.getDestinationUrl();
if(url.indexOf(‘{‘) >= 0) {
//Let’s remove 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 : entity, code : -1});
}
if(BAD_CODES.indexOf(response_code) >= 0) {
//This entity has an issue.  Save it for later.
bad_entities.push({e : entity, code : response_code});
}
already_checked[url] = true;
}
}
var column_names = [‘Type’,’CampaignName’,’AdGroupName’,’Id’,’Headline/KeywordText’,’ResponseCode’,’DestUrl’];
var attachment = column_names.join(“,”)+”\n”;
for(var i in bad_entities) {
attachment += _formatResults(bad_entities[i],”,”);
}
if(bad_entities.length > 0) {
var options = { attachments: [Utilities.newBlob(attachment, ‘text/csv’, ‘bad_urls_’+_getDateString()+’.csv’)] };
var email_body = “There are ” + bad_entities.length + ” urls that are broken. See attachment for details.”;
for(var i in TO) {
MailApp.sendEmail(TO[i], SUBJECT, email_body, options);
}
}
}
//Formats a row of results separated by SEP
function _formatResults(entity,SEP) {
var e = entity.e;
if(typeof(e[‘getHeadline’]) != “undefined”) {
//this is an ad entity
return [“Ad”,
e.getCampaign().getName(),
e.getAdGroup().getName(),
e.getId(),
e.getHeadline(),
entity.code,
e.getDestinationUrl()
].join(SEP)+”\n”;
} else {
// and this is a keyword
return [“Keyword”,
e.getCampaign().getName(),
e.getAdGroup().getName(),
e.getId(),
e.getText(),
entity.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”);
}

❤再看看呗❤

Google AdWords动态文本插入使用的3个技巧 动态文本插入/Dynamic Keyword Insertion/DKI功能是指,在广告语中使用{keyword:XXX}符号,当这个广告语被激活展示时,XXX会被搜索用户所触发的关键词文本所代替。举个例子,广告用户的广告语标题是正宗{keyword:豆腐花},搜索用户搜索甜的豆腐花,触发了关键词甜...
关于adwords出价调整规则的疑惑 一、问题 增强版的adwords有多处地方可以提高/降低广告的出价,带来的疑惑是不同方式的调整是否有优先级,以及多处对出价的调整是如何影响最终的出价的? 二、账户设置情况 目前账户有设置出价调整的地方有下面几处: 广告系列设置中的: 1.地理位置的出价调整 2.广告投放时间的出价调整...

本文出自 幽游网,转载时请注明出处及相应链接。

本文永久链接: http://www.yuyuhunter.com/post/adwords-link-check.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注

必须启用javascript才能看到验证图案!
Ɣ回顶部