Link Checker MCC

1,249 views
Skip to first unread message

Jonathan Cook

unread,
May 22, 2014, 9:02:43 AM5/22/14
to adwords...@googlegroups.com
Hi all,

I'm playing around with MCC level scripts and I'm having some issues with just getting the Link Checker MCC pre made script to work.


When running the script I am getting the error: TypeError: Cannot find function map in object XXX-XXX-XXXX. (line 96)

I'm just trying to run it one account for now in our MCC.

Function with the error:

function getAccountSelector(settings) {
 
var accountSelector = MccApp.accounts();
 
if (settings.accountsToCheck.length > 0) {
   
accountSelector = accountSelector.withIds(settings.accountsToCheck);
 
}
 
return accountSelector;
}

The bold line is line 96.

Anyone else had this issue or knows how to solve it? 

Thanks! 
 

Jens Petter Røyseth

unread,
May 27, 2014, 8:38:49 AM5/27/14
to adwords...@googlegroups.com
Hi Jonathan!

I have the exact same problem!

My steps were as following:
1. Opened a new spreadsheet, named it MCC test1.
2. I opened the Link Checker template spreadsheet.
3. From the template I copied the tabs "Dashboard" and "Report Template". I had to create an additional tab named "summary", as that is not included in the template, and that is where the script will look for the "lastrun" date. 
TypeError: Cannot call method "getRange" of null. (line 78)
Second time it runs, it also does not recognize the date format.

4. I paste in the Script and add the spreadsheet url.
5. I run the script and get following errors:
 
5.1 TypeError: Cannot find function map in object XXX-XXX-XXXX. (line 96)
My MCC has more than 50 accounts. If I fill in the account number of 1 account I want to check, I get that error. If I add more than 1 account id, separated by a comma (either written as XXX-XXX-XXXX or as XXXXXXXXXX) I get the same error. If I run it without specifying the accounts to check I get "

5.2
Second time it runs (and has failed, because the MCC has more than 50 accounts) I get the following error:
TimeLog
14:12:46.706
Fresh run...
14:12:47.173
Found matching labels: 0.0
14:12:47.290
Found matching labels: 0.0
14:12:47.391
Found matching labels: 0.0
14:12:48.229
TypeError: Cannot read property "keywordsLabel" from undefined. (line 155)

Line 155 looks like this:
function createLinkCheckerLabels(account, settings) {
 
var mccAccount = AdWordsApp.currentAccount();
 
MccApp.select(account);
 
var labelNames = [settings.keywordsLabel, settings.adsLabel,
      settings
.sitelinksLabel];



Any feedback on any/all of these errors would be very appreciated!
Kind regards.


Jonathan Cook

unread,
May 28, 2014, 4:41:56 AM5/28/14
to adwords...@googlegroups.com
Hi Jens,

The pretty much the same things I have done! I figured out adding the extra page on the spreadsheet. However I haven't come across a solution for the other error as of yet. At least I know its not just me having this issue, maybe someone from Google can jump on this now as its multiple users having the same issue.
Message has been deleted
Message has been deleted

Jonathan Cook

unread,
May 29, 2014, 5:05:15 AM5/29/14
to adwords...@googlegroups.com
Seems like the there's an issue somewhere then! p.s you left two IDs in your last example might want to remove them.

Andri Fried

unread,
May 29, 2014, 3:52:04 PM5/29/14
to adwords...@googlegroups.com
@Jonathan: Thx, I removed the post. Here it is again without the IDs

---------------------

Hey Guys,
pretty much the same thing here. MCC with more than 50 Accounts. 

TypeError: Cannot find function map in object XXX-XXX-XXXX. (line 96)

(when using XXX-XXX-XXXX format for one account)


Selector was too large. Cannot call executeInParallel on a selector with more than 50 elements. (line 35)

(when using XXXXXXXXXX format for one account OR leaving the field blank)



TypeError: Cannot find function map in object XXXXXXXXXX,XXXXXXXXXX. (line 96)

(when using XXXXXXXXXX format for two account, same happens using the other format)



@google:  Could you please help us on this? And could you please add the "summary" -tab in the template spreadsheet ? (It took me quit a while to figure it out).

Thx
- show quoted text -

Anash Oommen

unread,
Jun 12, 2014, 2:01:27 PM6/12/14
to adwords...@googlegroups.com
Hi everyone,

Could you take another look at the script and let me know if it works for you? I just pushed an updated version that fixes the issue about comma separated list of customer ids not working as expected.

Cheers,
Anash P. Oommen,
AdWords Scripts Team.

Andri Fried

unread,
Jun 16, 2014, 5:13:41 AM6/16/14
to adwords...@googlegroups.com
Hi everyone,
Thanks a lot for updating the script. It creates new tabs for every account in the spreadsheet now (format: "XXX-XXX-XXXX,XXX-XXX-XXXX"). The tabs remain empty, though.
I get these errors in the logs:

11:06:10.246
The label link_checker_keywords does not exist. (line 250)
11:06:11.062
The label link_checker_keywords does not exist. (line 250)
11:06:12.247
The label link_checker_keywords does not exist. (line 250)
11:06:15.315
TypeError: Cannot read property "accountsToCheck" from undefined. (line 100)

Any Idea how to fix this?

Your support is very much appreciated.
Cheers,
Andri

Anash Oommen

unread,
Jun 16, 2014, 9:05:42 PM6/16/14
to adwords...@googlegroups.com
Hi Andri,

I suspect that the spreadsheet url specified on the site might be incorrect. Are you using a copy of the spreadsheet mentioned in the source code?

Cheers,
Anash P. Oommen,
AdWords Scripts Team.

Andri Fried

unread,
Jun 17, 2014, 9:22:31 AM6/17/14
to adwords...@googlegroups.com
Hi Anash,

thank you for your answer. It's not the wrong spreadsheet, I just set up the script again with a copy of this spreadsheet.

/**
 * The URL of the tracking spreadsheet. This should be a copy of
 * https://docs.google.com/spreadsheet/ccc?key=0AmowUlwjV7BBdEQ5eDY2SUppdzVFVm9JMGJVUFNneWc#gid=1
 */

 I still get the same errors in the log.

14:34:16.734
The label link_checker_keywords does not exist. (line 250)
14:34:17.965
The label link_checker_keywords does not exist. (line 250)
14:34:19.540
The label link_checker_keywords does not exist. (line 250)
14:34:23.027
TypeError: Cannot read property "accountsToCheck" from undefined. (line 100)


Any Idea why it doesn't work as expected?

Thank you,
Andri
Message has been deleted
Message has been deleted

Neil Goldman

unread,
Jun 17, 2014, 6:52:39 PM6/17/14
to adwords...@googlegroups.com
Are you "Preview"ing this script, or running it? Preview won't actually create labels, which is probably why you're getting this error, and why the script seemingly doesn't run, because it relies on those labels. If you are running it and it isn't working, does the script finish successfully (even though it's not outputting), or does it exit with errors?

That fourth error occurs when the getAccountSelector function is called without passing a settings parameter. It's intentional, it should return all accounts if done that way, but to stop it from complaining, try changing line 100 to something like this

  if (typeof settings !== "undefined" && settings.accountsToCheck.length > 0) {


Hope this helps,
Neil

Andri Fried

unread,
Jun 18, 2014, 4:10:16 AM6/18/14
to adwords...@googlegroups.com
Thank you Neil! I've run the script several times (not in preview), I always got the error of my last post.
Today I ran the same script (no changes at all). Status: Complete but I got a new errors in the logs:

TimeLog
09:01:42.490
Fresh run...
09:01:43.024
Found matching labels: 0.0
09:01:43.151
Found matching labels: 0.0
09:01:43.266
Found matching labels: 0.0
09:01:43.618
Deleting 195.0 rows from 4
09:01:44.549
TypeError: Cannot read property "keywordsLabel" from undefined. (line 160)


There is still no output in the spreadsheet.
Any Idea what I could try next?

Thanks a lot!
Andri


P.S.
I just set up the script again. Just to be sure I didn't make any mistakes. I'm a little confused, for the new script I got the same error in the logs as I got for the script yesterday (not preview)

09:43:12.265
The label link_checker_keywords does not exist. (line 250)
09:43:16.514
TypeError: Cannot read property "accountsToCheck" from undefined. (line 100)

Is there kind of a delay until the labels are created? 
Is there anything I could possibly have done wrong?

Neil Goldman

unread,
Jun 18, 2014, 10:09:20 AM6/18/14
to adwords...@googlegroups.com
Creating labels, at least from my experience, is instant. Though I guess instant to a human could be ages to a server. I haven't written anything that uses labels this way, and I don't feel comfortable testing this script and having it spew labels all over my company's campaigns. I could set up a test MCC, but I'm being lazy, lol.

That first warning in your P.S. is probably just because it's the first time the script is being run and there are no ads labeled with "link_checker_label". Does it say the same thing every single time? Regardless, the script continues running after that, so I don't think that's the issue (otherwise we wouldn't be seeing that TypeError log after it).

Just to make sure we've covered the basics, you've copied the template spreadsheet and are using the URL of your new copy, not the original template. Is it emailing you when it finishes?
And this may seem really obvious, but do you have any broken URLs? If you're not sure, can you create an ad with an invalid link and try the script again?

Andri Fried

unread,
Jun 18, 2014, 11:02:56 AM6/18/14
to adwords...@googlegroups.com
Hey Neil, I really appreciate it that you're digging into this.

That first warning in your P.S. is probably just because it's the first time the script is being run and there are no ads labeled with "link_checker_label". Does it say the same thing every single time? Regardless, the script continues running after that, so I don't think that's the issue (otherwise we wouldn't be seeing that TypeError log after it).

Yeah, it always says the same thing, regardless how many times I run the script.

 

Just to make sure we've covered the basics, you've copied the template spreadsheet and are using the URL of your new copy, not the original template. Is it emailing you when it finishes?
And this may seem really obvious, but do you have any broken URLs? If you're not sure, can you create an ad with an invalid link and try the script again?

Basics should be ok, done it several times. (copy of the spreadsheet, pasted the URL of the copy into the code)
--> I do not get any emails
--> The script creates new tabs for every account checked, the tabs remain empty (no matter how many times I run the script)

I addad an invalid (404) link to one of the accounts and ran the script. Nothing changes. As far as I understand a broken link would not even be necessary

 The script maintains a spreadsheet that tracks all the accounts it checked, all the URLs checked so far today, and their statuses. It also sends you an email whenever it completes a run, so you can view the status of the checked URLs on the tracking spreadsheet.

 I guess there is something wrong with the script (at least I hope so, if not I would feel really stupid).
At least Jens Petter Røyseth reported the same Error on May 27 earlier in this thread.


5.2
Second time it runs (and has failed, because the MCC has more than 50 accounts) I get the following error:
TimeLog
14:12:46.706
Fresh run...
14:12:47.173
Found matching labels: 0.0
14:12:47.290
Found matching labels: 0.0
14:12:47.391
Found matching labels: 0.0
14:12:48.229
TypeError: Cannot read property "keywordsLabel" from undefined. (line 155)

Line 155 looks like this:
function createLinkCheckerLabels(account, settings) {
 
var mccAccount = AdWordsApp.currentAccount();
 
MccApp.select(account);
 
var labelNames = [settings.keywordsLabel, settings.adsLabel,
      settings
.sitelinksLabel];



Any feedback on any/all of these errors would be very appreciated!
Kind regards.

Cheers,
Andri

Neil Goldman

unread,
Jun 18, 2014, 1:23:28 PM6/18/14
to adwords...@googlegroups.com
No problem, Andri. It gives me a distraction at work, but it still looks like I'm coding scripts to the boss ;P

Line 28 of the script is the only call to createLinkCheckerLabels(). There is no settings argument provided, but createLinkCheckerLabels requires one to work. So that seems like a bug, and not something done intentionally. Try changing line 28 to this:
      createLinkCheckerLabels(account, settings);

Also, to stop it from breaking because you have over 50 accounts, you can change line 101 to this temporarily to solve that.
    accountSelector = accountSelector.withIds(settings.accountsToCheck).withLimit(50);

This will limit the accountSelector to only the first 50 matching accounts. This is because a single script can only operate on 50 accounts in parallel at a time. If you want to monitor more accounts than this, you'll need to manage this in your script somehow, to only process 50 at a time, and maybe use different scripts with different accounts, or have it be able to track which accounts it has processed so far, and continue doing the rest in a later run.

Hopefully applying those 2 solutions will have it working for you.

G'luck!
Neil

Andri Fried

unread,
Jun 19, 2014, 5:31:22 AM6/19/14
to adwords...@googlegroups.com
Great, happy to help you distract from work! 


Changing Line 28 as you said helped, the script creates the labels now. I can actually find them in the accounts, yay!
And yay, there are new errors in the log files and still no output (but creating tabs) in the spreadsheet: 

10:53:54.912
Invalid argument: https://www.XXXXX.com/XXXXXXXX-lp?ry=SEM%7CGoogle%7CSeeker%7CPC%7C{creative}%7C{keyword}%7C{device}_Seeker_Content%7Ccat%20blue%7C{matchtype}%7C{network} (line 315)

Line 315 is
  var response = UrlFetchApp.fetch(url, { muteHttpExceptions: true});



And the old (my preferred one!) TypeError:

10:54:03.725
TypeError: Cannot read property "accountsToCheck" from undefined. (line 100) 

Line 100 is
  if (settings.accountsToCheck.length > 0) {

 
I've run two different scripts (checking different accounts) several times, I get the same error for both scripts in all accounts. Any Idea why that could be?



Also, to stop it from breaking because you have over 50 accounts, you can change line 101 to this temporarily to solve that.
    accountSelector = accountSelector.withIds(settings.accountsToCheck).withLimit(50);

This will limit the accountSelector to only the first 50 matching accounts. This is because a single script can only operate on 50 accounts in parallel at a time. If you want to monitor more accounts than this, you'll need to manage this in your script somehow, to only process 50 at a time, and maybe use different scripts with different accounts, or have it be able to track which accounts it has processed so far, and continue doing the rest in a later run.


The script is really only checks the accounts I defined in the spreadsheet (only 3). So I guess there is no need to add .withLimit(50) , right?
I added it anyways, doesn't change anything, I still get the two errors above.


I wonder if anyone has tested the script before it was released on

Has anyone made the script actually running?

@Neil: Thanks a lot again for your help. Would be awesome if we (you!) could make this script work!

Best,
Andri

Neil Goldman

unread,
Jun 19, 2014, 12:26:37 PM6/19/14
to adwords...@googlegroups.com
I just looked through the script more carefully and spotted something really strange. Lines 251 and 270 are this:
.withCondition("DestinationUrl STARTS_WITH_IGNORE_CASE 'h'")
Which just makes no sense. Why would we only want to check URLs that begin with the letter 'h'? Unless there's something weird about AdWords that I don't understand (I'm still pretty new to AdWords), this is probably causing it to ignore a lot, or all, of the links. Simply deleting each of these lines should fix that. Make sure to leave the other .withCondition() lines and etc in the script, and only delete the ones about STARTS_WITH.

See if that change helps/works, otherwise, continue reading, lol.


That error on line 315 just looks like an invalid URL getting passed through. It's probably the parameters like {network}. Because "{" and "}" are invalid URL characters, and the UrlFetchApp sees it and refuses to load it. This isn't that big of a deal, it shouldn't be crashing your script. You can try removing the url query within the script if you want to be able to test it too, though. Something like:  
url = url.substr(0, url.indexOf('?'));

You could place this just before line 315. This will strip everything after the '?' in a URL, leaving you with just "https://www.XXXXX.com/XXXXXXXX-lp". The downside of this is you can't check any URLs that depend on the query doing something. (e.g. 'mysite.com/?p=home' and 'mysite.com/?p=blog' will both be trimmed to 'mysite.com'). You could put this in a try/catch statement and get the best of both worlds, but now I'm getting ahead of myself. Unless all of your links are like this format and give errors, then I'm positive this isn't the issue.


That line 100 error is definitely the preferred one, lol. Now that I look at it more closely, maybe it isn't intentional. If getAccountSelector() is called without providing any settings, it should return EVERY account, which generally makes sense. But it doesn't seem to make sense for this script. You could try changing line 329 to this:
(It might not be line 329 after adding the changes I mentioned earlier. So I'm providing the surrounding lines of code as well):
  clearSummarySheet(spreadsheet);
  updateCheckedUrlSummary(spreadsheet, settings); //change this line
  sendEmails(settings);

and then change lines 374 & 375 to:
function updateCheckedUrlSummary(spreadsheet, settings) {
  var accountSelector = getAccountSelector(settings).get();


The script is really only checks the accounts I defined in the spreadsheet (only 3). So I guess there is no need to add .withLimit(50) , right?
You're correct, the withLimit(50) isn't necessary if you're just checking a few accounts, but it also never hurts.

Try those out, see if the changes help. I feel like all the above should be the solution. If not, some more questions:

Does the log ever reach a point where it prints something like "Account: 123456789, good urls: 0, bad urls: 0',"?
It should print this when the script is almost completed.

Does the  log ever print something like 'Checking 1 keywords.' Instead of keywords it can also say 'ads' or 'sitelinks'
It should print this right before it tests the URLs for each account's keywords/ads/sitelinks, even if the result is 0.
 
Can you add this line after line 380 (it might be a slightly different line number because of the edits made earlier). Here's the line, along with the 2 line's preceding it so you know where to place it.
  while (accountSelector.hasNext()) {
    var account = accountSelector.next();
    Logger.log("Checking account: " + account.getName()); //new line

This should log every account being checked. You can preview the script again and confirm that it's actually seeing the accounts listed in the spreadsheet, and at least trying to do something with them.

It certainly doesn't seem like this script was tested before release, but who knows. Most of the other google solutions and snippets have been flawless so far.

There's also some other good resources for link checker scripts that I think might be better than this one. Russel Savage posts a lot of free adwords scripts and resources. Here's an MCC level link checker. I haven't personally tried this script.

I did use Mr Savage's non-MCC link-checker script as a base to create my own MCC link-checker. So I know his scripts are very good.

Hopefully it'll be fixed this time!
Neil

Andri Fried

unread,
Jun 23, 2014, 8:49:17 AM6/23/14
to adwords...@googlegroups.com
Yay, the script seems to work now! Awesome, thx a lot!




On Thursday, June 19, 2014 6:26:37 PM UTC+2, Neil Goldman wrote:
I just looked through the script more carefully and spotted something really strange. Lines 251 and 270 are this:
.withCondition("DestinationUrl STARTS_WITH_IGNORE_CASE 'h'")
Which just makes no sense. Why would we only want to check URLs that begin with the letter 'h'? Unless there's something weird about AdWords that I don't understand (I'm still pretty new to AdWords), this is probably causing it to ignore a lot, or all, of the links. Simply deleting each of these lines should fix that. Make sure to leave the other .withCondition() lines and etc in the script, and only delete the ones about STARTS_WITH.

I did not change anything, AdWords always adds http/https to the URLs. So it should be ok I guess.

 

That error on line 315 just looks like an invalid URL getting passed through. It's probably the parameters like {network}. Because "{" and "}" are invalid URL characters, and the UrlFetchApp sees it and refuses to load it. This isn't that big of a deal, it shouldn't be crashing your script. You can try removing the url query within the script if you want to be able to test it too, though. Something like:  
url = url.substr(0, url.indexOf('?'));

That really fixed it! The parameters after ? do not matter in my case, I really just use it for tracking purposes.
 
You could place this just before line 315. This will strip everything after the '?' in a URL, leaving you with just "https://www.XXXXX.com/XXXXXXXX-lp". The downside of this is you can't check any URLs that depend on the query doing something. (e.g. 'mysite.com/?p=home' and 'mysite.com/?p=blog' will both be trimmed to 'mysite.com'). You could put this in a try/catch statement and get the best of both worlds, but now I'm getting ahead of myself. Unless all of your links are like this format and give errors, then I'm positive this isn't the issue.


That line 100 error is definitely the preferred one, lol. Now that I look at it more closely, maybe it isn't intentional. If getAccountSelector() is called without providing any settings, it should return EVERY account, which generally makes sense. But it doesn't seem to make sense for this script. You could try changing line 329 to this:
(It might not be line 329 after adding the changes I mentioned earlier. So I'm providing the surrounding lines of code as well):
  clearSummarySheet(spreadsheet);
  updateCheckedUrlSummary(spreadsheet, settings); //change this line
  sendEmails(settings);

and then change lines 374 & 375 to:
function updateCheckedUrlSummary(spreadsheet, settings) {
  var accountSelector = getAccountSelector(settings).get();

This seems to have fixed the second error. The script runs without errors. Great!

 

There's also some other good resources for link checker scripts that I think might be better than this one. Russel Savage posts a lot of free adwords scripts and resources. Here's an MCC level link checker. I haven't personally tried this script.

I did use Mr Savage's non-MCC link-checker script as a base to create my own MCC link-checker. So I know his scripts are very good.

Lol, yeah, I've tried that script as well ;-) 


Worked for some accounts. But I felt like I should be able to have the script running the google guys set up ;-)

 
Hopefully it'll be fixed this time!
Neil

It did fix it, thank you so much!
(-> I'll just have it run in all accounts to check if any errors might show up)

Best,
Andri


P.S.
What do you think, should I publish the final code I'm using in this thread? 



 
G'luck!

TypeError: Cannot find <span sty
...
Reply all
Reply to author
Forward
0 new messages