Adword 脚本,用于暂停最终到达网址为 404 重定向的关键字

Adword script that pause's keywords where the final URL is a 404 redirect?

本文关键字:重定向 关键字 脚本 用于 暂停 Adword      更新时间:2023-09-26

是否可以创建一个Adwords脚本,如果最终网址重定向到404,该脚本将暂停关键字?并在 URL 更正时启用它们?

我知道常见的链接检查器脚本,但它仅在 URL 错误时通知您?它不执行任何操作。

这可能吗?

谢谢

布隆。

是的

,代码看起来像这样:

function main(){
$_Keywords = AdWordsApp.keywords()
.get()
while ($_Keywords.hasNext())
{
    $_Keyword = $_Keywords.next()
    try {
        var $_Response = UrlFetchApp.fetch($_Keyword.urls().gerFinalUrl(), {muteHttpExceptions: true});
        $_ResponseCode = $_Response.getResponseCode();
    }   catch (e) {
        //Presuming something went wrong here
        $_Keyword.pause()
    }
    if ($_ResponseCode == 404)
    {
        $_Keyword.pause()
    }
}

}