Link Checker script from AdWords Script's Solutions section

2,052 views
Skip to first unread message

Oleg Amirdzhanov

unread,
Aug 19, 2013, 5:16:58 PM8/19/13
to adwords...@googlegroups.com
Greetings,

I am currently evaluating the Link Checker script found @ https://developers.google.com/adwords/scripts/docs/solutions/link-checker and for some reason URLs are not being recorded into the spreadsheet unless at least a single broken URL is found during that specific run.  In this case both, broken and good URLs are populated into spreadsheet.  I also couldn't get the number of good and bad links to display on dashboard page.  This number is also fails to appear on emails when it comes with alert that bad links were found.  If no bad links were found email alerts arrive with nothing at all in the email body.

I was wondering if anyone else had same issues with this script, which otherwise is a perfect solution for bad/broken URLs.  The issues above do not take away from main functionality, but I couldn't figure out why it is happening, because everything looks good on the script.  

Also the following line of code resulted in invalid operation error:

Utilities.sleep(1000 - (then - now));

which was easily corrected by omitting 1000, so the following works w/o producing an error:

Utilities.sleep(then - now);


Any feedback is greatly appreciated!

Thanks,

_oleg

Anash Oommen

unread,
Aug 20, 2013, 3:45:58 AM8/20/13
to adwords...@googlegroups.com
Hi Oleg,

There's a specific check in the code to take action only if a bad url was found. Just look for the code snippet that looks like:
if (anythingChanged) {
    shelper
.flush();
   
if (badUrls > 0 && shelper.config.email.length > 0 && shelper.config.emailPreference == "As soon as an error is discovered")
It is towards the beginning of the script, about line 20.

Cheers,
Anash P. Oommen,
AdWords Scripts Team

Oleg Amirdzhanov

unread,
Aug 20, 2013, 10:24:09 AM8/20/13
to adwords...@googlegroups.com
Thank you Anash, this script was one of our top wanted features, and though we have worked out our own versions, they are now scratched and slightly customized version of this script is a solution we've been looking for.  Thanks again...

_oleg

Oleg Amirdzhanov

unread,
Aug 20, 2013, 2:36:26 PM8/20/13
to adwords...@googlegroups.com
I also get Those rows are out of bounds. (line 221) error after just 200 lines have been filled on spreadsheet , I am not sure if I've reached the daily quota by running too many tests or script fails to expand the spreadsheet beyond 200 rows... 

Oleg Amirdzhanov

unread,
Aug 20, 2013, 5:06:47 PM8/20/13
to adwords...@googlegroups.com
Now second account produced the same Those rows are out of bounds. (line 221) error as it reached line 199 on the report spreadsheet.  Is it a necessary limitation? I have trouble following it within the code, where MAX_ROWS defined as 20K 

Oleg Amirdzhanov

unread,
Aug 21, 2013, 10:56:15 AM8/21/13
to adwords...@googlegroups.com
Now confirmed with multiple accounts... As soon as reporting spreadsheet is filled with 199 entries, Those rows are out of bounds. (line 221) error stops the execution and that is pretty much it.  Is it the script that enforces this kind of limitation or is it some setting within spreadsheet that limits it to only 199 rows?  Please advise...  Thanks

_oleg


On Tuesday, August 20, 2013 3:45:58 AM UTC-4, Anash Oommen wrote:

Patrick

unread,
Aug 21, 2013, 11:01:43 AM8/21/13
to adwords...@googlegroups.com
Hi Oleg,

Did you tried to enhance the rows of the spreadsheet manually??
I might be wrong, but I think that 200 is the "natural" limit of a new sheet but it's possible to add rows (at the bottom of the spreadsheet on the left side)...



Let me know if this works out, I'm pretty interested in that script.

Cheers,

Oleg Amirdzhanov

unread,
Aug 21, 2013, 11:49:33 AM8/21/13
to adwords...@googlegroups.com
It absolutely worked...  I had a thought about that early but for some reason thought it would only increment by 20..  Big thanks!

Cyprien

unread,
Aug 22, 2013, 4:09:19 AM8/22/13
to adwords...@googlegroups.com
Hi guys,

Using the script, I'm coming up with this error :

DNS error: http://klmede.com (line 110)

Do you know where it can come from ?

(http://klmede.com has nothing to do with my client's website)

Cheers,

Cyprien

Anash Oommen

unread,
Aug 23, 2013, 9:03:47 AM8/23/13
to adwords...@googlegroups.com
Hi Cyprien,

My guess is that there's an ad by that destination url in your client's account, but may be your client (or the developer who managed the account before you) created it some time in the past just to test out things?

Cheers,
Anash P. Oommen,
AdWords Scripts Team

Cyprien

unread,
Aug 26, 2013, 7:36:46 AM8/26/13
to adwords...@googlegroups.com
Hi Anash,

You were right, it was a testing URL in a deleted campaign, that's why I didn't find it.

So I tried to modify the link checker script to verify only enabled ads in enabled adgroups in enabled campaigns.
But I failed to make it work.

Can anyone help with this ? I guess it will be useful for many of us.

Thanks again.

Cyprien

Anash Oommen

unread,
Aug 28, 2013, 5:12:55 AM8/28/13
to adwords...@googlegroups.com
Hi Cyprien,

I'll try to enhance this code example a bit more to suggest how certain modifications may be done, but for now, this is the part you are looking for:
  var anythingChanged = shelper.config.checkKeywords && checkUrls(AdWordsApp.keywords());
  anythingChanged
= (shelper.config.checkAds && checkUrls(AdWordsApp.ads())) || anythingChanged;
AdWordsApp.keywords()
should become

AdWordsApp.keywords().withCondition("Status = ACTIVE")

You can find the necessary column name for filtering on the API reports page under the corresponding report: https://developers.google.com/adwords/api/docs/appendix/reports#keywords

Cheers,
Anash P. Oommen,
AdWords Scripts Team

Patrick

unread,
Aug 28, 2013, 6:32:59 AM8/28/13
to adwords...@googlegroups.com
Hi Guys,

I tried the script in several accounts but I receive almost every time an error:



I copied the script from the documentation in to the editor and didn't change anything beside the spreadsheet URL....
I really apreciate your help on this one !

Thanks in advance.

Cyprien

unread,
Aug 28, 2013, 8:16:30 AM8/28/13
to adwords...@googlegroups.com
Hi Patrick,

Can you try to make the following change in the code (see previous message from Oleg in this discussion)

The following line of code resulted in invalid operation error:

Utilities.sleep(1000 - (then - now));

which was easily corrected by omitting 1000, so the following works w/o producing an error:

Utilities.sleep(then - now);


@Anash : thank you for your previous message

Cheers,

Cyprien

Andrei Stoicescu

unread,
Nov 6, 2013, 3:52:56 AM11/6/13
to adwords...@googlegroups.com
Hi,

I need some help with this script, I get the following error:
The label link_checked does not exist. (line 96)

Please advice, thank you!

Acest e-mail este de la Creative Build Solutions.
Acest e-mail este adresat doar destinatarului si poate contine informatii confidentiale sau privilegiate.
Daca primiti acest e-mail, din greseala, va rugam sa nu dezvaluiti continutul, inclusiv orice atasamente, altei persoane, sa-l utilizati sau sa copiati informatiile.
In schimb va rugam sa notificati expeditorul si sa stergeti acest e-mail, inclusiv orice atasamente din sistem.
Multumim.

Oleg Amirdzhanov

unread,
Nov 6, 2013, 3:40:14 PM11/6/13
to adwords...@googlegroups.com
Either check your code for anything preventing to create the label exactly the way it is spelled in the error message below (capitalization matters).  Or simply manually create one in AdWords UI and this will go away

Andrew Samuels

unread,
Nov 8, 2013, 5:44:37 PM11/8/13
to adwords...@googlegroups.com
I am also trying to use the Link Checker but I am receiving TypeError: Cannot call method "setValue" of null. (line 61).
I followed step by step on the scripts page and copy and pasted the code in (java is not one of my strong suits) and it errors at that point causing the code not to run.

Anash Oommen

unread,
Nov 11, 2013, 3:35:30 PM11/11/13
to adwords...@googlegroups.com
Hi Andrew,

You need to check your spreadsheet, line 61 is looking for a named range called account_id_report in the spreadsheet. It is defined as Report!E2:G2 on the original template spreadsheet.

Cheers,
Anash P. Oommen,
AdWords Scripts Team

Andrew Samuels

unread,
Nov 11, 2013, 5:35:05 PM11/11/13
to adwords...@googlegroups.com
I got my error fixed and the link checker running for that Client. When I went to put it in for a new client and changed the spreadsheeturl to the new one I am now receiving link_checked does not exist line 95

Line 95 is   var iterator = AdWordsApp.keywords()
96    .withCondition("DestinationUrl STARTS_WITH_IGNORE_CASE 'h'")
97    .withCondition("LabelNames CONTAINS_NONE['" + LABEL_NAME + "']")
98   .orderBy("DestinationUrl")
99    .withLimit(800)
100    .get();

Andy

unread,
Dec 11, 2013, 4:30:05 PM12/11/13
to adwords...@googlegroups.com


Am Mittwoch, 28. August 2013 11:12:55 UTC+2 schrieb Anash Oommen:
Hi Cyprien,

I'll try to enhance this code example a bit more to suggest how certain modifications may be done, but for now, this is the part you are looking for:
  var anythingChanged = shelper.config.checkKeywords && checkUrls(AdWordsApp.keywords());
  anythingChanged
= (shelper.config.checkAds && checkUrls(AdWordsApp.ads())) || anythingChanged;
AdWordsApp.keywords()
should become

AdWordsApp.keywords().withCondition("Status = ACTIVE")

You can find the necessary column name for filtering on the API reports page under the corresponding report: https://developers.google.com/adwords/api/docs/appendix/reports#keywords

Cheers,
Anash P. Oommen,
AdWords Scripts Team

HI

I have the same problem like Cyprien. An i have change the code to:
 var anythingChanged = shelper.config.checkKeywords && checkUrls(AdWordsApp.keywords().withCondition("Status = ACTIVE"));
  anythingChanged = (shelper.config.checkAds && checkUrls(AdWordsApp.ads())) || anythingChanged;

May i have every time a running time error.
DNS error: http://ww.xyz.com/index.php (line 111) 

The problem is the ww.xyz.com (ww -> www). May i can't find this wrong URL in the AdWords Account. No aktive no deleted Kampagne or Keyword ha's this URL. I don't understand this.

I don't know what i can do?

Thanks for your help.

Patrick

unread,
Dec 12, 2013, 3:39:36 AM12/12/13
to adwords...@googlegroups.com
Hi Andy,

Did you check your ads too?
I had the same problem on a deleted ad in a paused campaign. I changed the script to scan only active campaigns and adgroups so I don't loose time by scanning entities that aren't relevant.

Greetings,

Andy

unread,
Dec 12, 2013, 3:43:25 AM12/12/13
to adwords...@googlegroups.com
Hi Patrick

No, i can't find this URL in my Account. I have search many times, i don't no, where this is :-(

Can you post the Code for check only active campaigns & keywords? My script is dosen't work :-(.

Many thanks for your help.

Andy

Patrick

unread,
Dec 12, 2013, 4:03:58 AM12/12/13
to adwords...@googlegroups.com
HI Andy,

I took the basic script and modified it on 3lines ;)
var anythingChanged = shelper.config.checkKeywords && checkUrls(AdWordsApp.keywords().withCondition("CampaignStatus = ACTIVE"));
  anythingChanged = (shelper.config.checkAds && checkUrls(AdWordsApp.ads().withCondition("CampaignStatus = ACTIVE"))) || anythingChanged;
112 Utilities.sleep(then - now);

That's it, and it works just fine.

Cheers,

Muther Boards

unread,
Feb 17, 2014, 11:59:54 PM2/17/14
to adwords...@googlegroups.com
I also receive the same error as Patrick.

Invalid argument: http://www.hidden.<?>/?xid=sem-Brand%20%3E%20hidden-hidden-{keyword} (line 112)

I tried your fix, but to no avail. 

Ezinete de Oliveira Gomes

unread,
Feb 20, 2014, 7:29:50 AM2/20/14
to adwords...@googlegroups.com
Hi Muther and Patrick, 

The flag fetch (url, params) to disable scaping UrlFetchApp method did not work for me (https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app

But I managed to fix the error using encodeURI () and encodeURIComponent () JavaScript (http://www.w3schools.com/jsref/jsref_escape.asp

I hope this helps you. 

Att, 
Ezinete

Muther Boards

unread,
Feb 26, 2014, 7:22:09 PM2/26/14
to adwords...@googlegroups.com
Can you please show how you edited the code to successfully pass through the URL? I tihnk because my url has non-standard characters in it, it is breaking the script. 

Muther Boards

unread,
Feb 26, 2014, 7:33:13 PM2/26/14
to adwords...@googlegroups.com
I added this on line 111 to fix the script:

lastUrl = encodeURI(lastUrl);


Thanks


On Thursday, February 20, 2014 11:29:50 PM UTC+11, Ezinete de Oliveira Gomes wrote:

joaquin....@iprospect.com

unread,
Mar 5, 2014, 4:15:49 PM3/5/14
to adwords...@googlegroups.com
Thank you very much, that fixed the scrip!

Muditha Dahanayaka

unread,
Mar 17, 2014, 2:47:34 AM3/17/14
to adwords...@googlegroups.com
Hi Patric

Need some help with my script. At the moment I'm implementing the link checker script in to a very large and complex account.
I want to modify the code to avoid the script from considering non active campaigns, non active ad groups and non active ads all at the same time.

could you please help me?

Patrick

unread,
Mar 17, 2014, 3:54:59 AM3/17/14
to adwords...@googlegroups.com
Hi Muditha,

Have you already tried out to add a second condition like this:
var anythingChanged = shelper.config.checkKeywords && checkUrls(AdWordsApp.keywords().withCondition("CampaignStatus = ACTIVE").withCondition("AdGroupStatus = ENABLED");

Muditha Dahanayaka

unread,
Mar 17, 2014, 3:57:19 PM3/17/14
to adwords...@googlegroups.com
Hi Patrick

You are amazing. It worked. Thanks.Have a good day.

Cheers
Mudi

Muditha Dahanayaka

unread,
Mar 17, 2014, 6:05:16 PM3/17/14
to adwords...@googlegroups.com
Hi Patrick

IF i want to check active ads at the same time the script checks for active campaigns and active ad groups how should i change the code?

is the following code written correctly?
var anythingChanged = shelper.config.checkKeywords && checkUrls(AdWordsApp.keywords().withCondition("CampaignStatus = ACTIVE").withCondition("AdGroupStatus = ENABLED").withCondition("AdStatus = ACTIVE");

Cheers
Mudi
On Monday, March 17, 2014 8:54:59 PM UTC+13, Patrick wrote:

Patrick

unread,
Mar 18, 2014, 4:43:32 AM3/18/14
to adwords...@googlegroups.com
Hi Muditha,

If you want to check on the ads, the you need to do the following:
var anythingChanged = shelper.config.checkKeywords && checkUrls(AdWordsApp.keywords().withCondition("CampaignStatus = ACTIVE").withCondition("AdGroupStatus = ENABLED").withCondition("Status = ENABLED");
You are allready on the "adlevel" so you don't need to precise that you want to filter on the status of the ads.
For the different conditions you can check on the "selector" references of the documentation ;) https://developers.google.com/adwords/scripts/docs/reference/adwordsapp

Cheers,

Muditha Dahanayaka

unread,
Mar 18, 2014, 3:08:25 PM3/18/14
to adwords...@googlegroups.com
Cool.
Thanks Patrick. Awesome.

J Vildosola

unread,
Jul 15, 2014, 9:57:33 AM7/15/14
to adwords...@googlegroups.com
Hi, I tried to fix the problem caused by having special charcters in the URL by adding the line: "lastUrl = encodeURI(lastUrl);"

The script executes without errors but all checked URLs are generating 404 error messages. This is the code I'm using:


    if (entity.getDestinationUrl() != lastUrl) {
      lastUrl = entity.getDestinationUrl();
      lastUrl = encodeURI(lastUrl);           // this is the line added
      var now = new Date().getTime();
      var response = UrlFetchApp.fetch(lastUrl, { muteHttpExceptions: true} );
      var then = new Date().getTime();
      Utilities.sleep(then - now);
      if (response.getResponseCode() < 300) {
        shelper.writeRow(lastUrl, response.getResponseCode());
 

I'm not shure if the added line is in the wrong place or if the original URL and the encoded URL are taken as the same URL when UrlFetchApp.fetch makes the fetch request. Could some one help? 

Thanks
Joaquin  


El miércoles, 26 de febrero de 2014 21:33:13 UTC-3, Muther Boards escribió:

Anash Oommen

unread,
Aug 6, 2014, 8:46:49 AM8/6/14
to adwords...@googlegroups.com
Hi,

Could you post a url that failed?

Cheers,
Anash P. Oommen,
AdWords Scripts Team.

Chris

unread,
Nov 20, 2014, 7:41:16 AM11/20/14
to adwords...@googlegroups.com
I am also trying to use the Link Checker but I am receiving Invalid argument: http://xyz.del (line 135)
I followed step by step on the scripts page and copy and pasted the code in  and it errors at that point causing the code not to run.

Matt Greenland

unread,
Dec 2, 2014, 9:05:58 PM12/2/14
to adwords...@googlegroups.com
Hi Chris,

Do any of your keywords or ads? If so, the tags like "{keyword}" or "{lpurl}" contain curly braces, which aren't allowed in URLs and will cause UrlFetchApp to blow up like this. The easiest thing to do to get around this would be to skip any URLs that contain these characters, although it might also be possible to substitute in fake data if needed.

Team Magnetizmo

unread,
Nov 17, 2016, 2:26:40 PM11/17/16
to AdWords Scripts Forum

Hi, I have enabled this script and it works great. But i have a lot of accounts linked to my MMC and only manager some of them. How do you change the script to only include those accounts i manage? This is the piece of script i need to edit i would imagine but i am unsure what i put in here. account numbers gives me an error.
// A list of ManagedAccountSelector conditions to restrict the population
// of child accounts that will be processed. Leave blank or comment out
// to include all child accounts.
ACCOUNT_CONDITIONS: [],
Any help would be greatly appreciated.
Thanks

Tyler Sidell (AdWords Scripts Team)

unread,
Nov 17, 2016, 3:11:31 PM11/17/16
to AdWords Scripts Forum
Hi,

In your MCC Link Checker script, you would need to modify ACCOUNT_CONDITIONS: [] as follows:
ACCOUNT_CONDITIONS: ["ManagerCustomerId IN ['CID1','CID2']"],

In the future, please open a new thread for better tracking purposes.

Thanks,
Tyler Sidell
AdWords Scripts Team
Reply all
Reply to author
Forward
0 new messages