Broken URL Script - Can it be expanded to notify 301 redirects?

314 views
Skip to first unread message

Dennison Packer

unread,
Mar 21, 2017, 9:30:42 AM3/21/17
to AdWords Scripts Forum
Hi everyone,

I'm using the Broken Link Checker script found here, but the script is not picking up any ads that redirect as a result of pointing to HTTP where there is then a 301 redirect to HTTPS.

Does anyone know of a way to amend the script to cover off 301s? Do these HTTP > HTTPS redirects even throw up a 301?


Any support would be greatly appreciated, we'd love to expand the script to cover off this type of redirect when vetting new accounts.


Many thanks,
Dennison


Anthony Madrigal

unread,
Mar 21, 2017, 9:45:23 AM3/21/17
to AdWords Scripts Forum
Hi Dennison,

If you want to include redirect codes to your Link Checker spreadsheet, you can change the following code:
responseCode =
       
UrlFetchApp.fetch(url, {muteHttpExceptions: true}).getResponseCode();

to 

responseCode =
       
UrlFetchApp.fetch(url, {muteHttpExceptions: true,followRedirects:false}).getResponseCode();

Please let me know if you still don't see these URLs in your spreadsheet.

Cheers,
Anthony
AdWords Scripts Team

Dennison Packer

unread,
Mar 22, 2017, 12:21:02 PM3/22/17
to AdWords Scripts Forum
Hi Anthony, thanks so much for your help on the subject. I've tested this and we're all good now - 301 codes are being picked up as desired.

Have a great day!

Dennison
Reply all
Reply to author
Forward
0 new messages