function getAccountSelector(settings) {
var accountSelector = MccApp.accounts();
if (settings.accountsToCheck.length > 0) {
accountSelector = accountSelector.withIds(settings.accountsToCheck);
}
return accountSelector;
}
TypeError: Cannot call method "getRange" of null. (line 78)
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:
Time | Log |
---|---|
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.
Seems like the there's an issue somewhere then! p.s you left two IDs in your last example might want to remove them.
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)
|
(when using XXXXXXXXXX format for two account, same happens using the other format)
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)
/**
* The URL of the tracking spreadsheet. This should be a copy of
* https://docs.google.com/spreadsheet/ccc?key=0AmowUlwjV7BBdEQ5eDY2SUppdzVFVm9JMGJVUFNneWc#gid=1
*/
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)
if (typeof settings !== "undefined" && settings.accountsToCheck.length > 0) {
Time Log 09:01:42.490 Fresh run...09:01:43.024 Found matching labels: 0.009:01:43.151 Found matching labels: 0.009:01:43.266 Found matching labels: 0.009:01:43.618 Deleting 195.0 rows from 409:01:44.549 TypeError: Cannot read property "keywordsLabel" from undefined. (line 160)
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)
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?
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.
5.2
Second time it runs (and has failed, because the MCC has more than 50 accounts) I get the following error:
Time Log
14:12:46.706 Fresh run...14:12:47.173 Found matching labels: 0.0
14:12:47.290 Found matching labels: 0.014: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.
createLinkCheckerLabels(account, settings);
accountSelector = accountSelector.withIds(settings.accountsToCheck).withLimit(50);
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)
var response = UrlFetchApp.fetch(url, { muteHttpExceptions: true});
10:54:03.725 |
TypeError: Cannot read property "accountsToCheck" from undefined. (line 100)
|
if (settings.accountsToCheck.length > 0) {
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.
.withCondition("DestinationUrl STARTS_WITH_IGNORE_CASE 'h'")
url = url.substr(0, url.indexOf('?'));
clearSummarySheet(spreadsheet); updateCheckedUrlSummary(spreadsheet, settings); //change this line sendEmails(settings);
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?
while (accountSelector.hasNext()) { var account = accountSelector.next(); Logger.log("Checking account: " + account.getName()); //new line
I just looked through the script more carefully and spotted something really strange. Lines 251 and 270 are this: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.
.withCondition("DestinationUrl STARTS_WITH_IGNORE_CASE 'h'")
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 linesendEmails(settings);and then change lines 374 & 375 to:
function updateCheckedUrlSummary(spreadsheet, settings) {var accountSelector = getAccountSelector(settings).get();
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
G'luck!
...
TypeError: Cannot find <span sty