暂停关键字的Adword脚本,其中最终的网址是404重定向?

时间:2016-02-02 16:09:18

标签: javascript scripting google-adwords

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

我知道常见的链接检查器脚本,但只会在URL错误时通知您?它没有任何动作。

这可能吗?

谢谢,

Broon。

1 个答案:

答案 0 :(得分:0)

是的,代码看起来像这样:

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()
    }
}

}