Issues with Setting Keyword-level Final URL

19 views
Skip to first unread message

Brian Park

unread,
Aug 25, 2015, 4:49:17 PM8/25/15
to AdWords Scripts Forum
Hi,

I'm having some trouble with working with the setting URLs at the keyword level when using Google Scripts. Here's a sample of what I am running:

function main() {
var keywordSelector = AdWordsApp.keywords()
.withCondition('FinalUrls = ""')
.forDateRange("TODAY")
.orderBy("Clicks DESC");


var keywordIterator = keywordSelector.get();
while (keywordIterator.hasNext()) {
var keyword = keywordIterator.next();
var keywordId = keyword.getId();

if(keywordID = 44668992664) {
            keyword.setFinalUrl('http://exampleurl.com')
          }
}


}

After running the script, the console shows an error stating"Cannot find function setFinalUrl in object". Please help!

Tyler Sidell (AdWords Scripts Team)

unread,
Aug 25, 2015, 4:57:40 PM8/25/15
to AdWords Scripts Forum
Hi Brian,

Please change 
keyword.setFinalUrl('http://exampleurl.com')

to
keyword.urls().setFinalUrl('http://exampleurl.com')

That should do the trick.  Also, as an unrelated suggestion I would recommend to add withIds to your selector instead of doing it in the while loop.  This will help to optimize your code.

Thanks,
Tyler Sidell
AdWords Scripts Team

Brian Park

unread,
Aug 25, 2015, 5:13:41 PM8/25/15
to AdWords Scripts Forum
Thanks Tyler! The script now runs as intended! 
Reply all
Reply to author
Forward
0 new messages