URL checker couple questions

123 views
Skip to first unread message

Michał Fidelus

unread,
Jul 21, 2015, 6:38:00 AM7/21/15
to adwords...@googlegroups.com
hello,

I got couple questions about google url checker script from https://developers.google.com/adwords/scripts/docs/solutions/link-checker and i hope You guys could help me out. 
I'm relatively new to AdWords and completely new to scripts  feature in Adwords  but feel it would be extremely usefull since i manage with my buddy 50+ accounts with even  40k ads per account.
We already got all urls in our campaigns as final urls since we upadated them manually so the script would work

1.Single account version of scripts seems to be working alright but when i turn off keyword option in spreadsheet and want to check ads only it seems to bo not checking anything ? any idea why ?
2.MCC version of script spits out empty spreadsheet when i select just 1 account, it looks like it checked something but script is done in 10 s so i guess something is wrong ;/
3.how to make it bypass 20k url limitation ? its really needed since we got massive ammounts of urls to check.. at least 40k. Do i need to make another account and put 1 for 1st 20? and another for 2nd 20k? How do i divide campaigns to check on account  so scripts wont check same urls twice ?
4.Is there any way for it to check for redirects ?
5.Is there any way of adding to this script or is there any similar script that is able to check only given labels ? Like i just need to check 1 campaign from 1 account, so i just put label on it and run ?

thanks in advance!

Tyler Sidell (AdWords Scripts Team)

unread,
Jul 21, 2015, 1:08:57 PM7/21/15
to adwords...@googlegroups.com
Hi Michal,

Welcome to AdWords.  I'd be glad to help you out with the questions that you had.  Please see my responses in bold below:

1.Single account version of scripts seems to be working alright but when i turn off keyword option in spreadsheet and want to check ads only it seems to bo not checking anything ? any idea why ?
Would you be able to provide your CID (reply privately to the author) along with the name of the script?  I would have to take a look to see at the modifications that were made.  Also are you receiving any errors in the log?

2.MCC version of script spits out empty spreadsheet when i select just 1 account, it looks like it checked something but script is done in 10 s so i guess something is wrong ;/
The MCC version iterates through all of your accounts.  You can either filter the account by setting a .withCondition or customizing the spreadsheet with the list of accounts that you would like to check.  For more information on customizing the spreadsheet, please check the "Configuring the Script" and "How it works" sections.

3.how to make it bypass 20k url limitation ? its really needed since we got massive ammounts of urls to check.. at least 40k. Do i need to make another account and put 1 for 1st 20? and another for 2nd 20k? How do i divide campaigns to check on account  so scripts wont check same urls twice ?
If your accounts have more than 20,000 URLs, then you can schedule multiple copies of the script under different user logins, and configure each instance to process a subset of your accounts.

4.Is there any way for it to check for redirects ?
You could include the parameter followRedirects and set it to true. In the link checker you would add this parameter to:
var response = UrlFetchApp.fetch(url, { muteHttpExceptions: true});

5.Is there any way of adding to this script or is there any similar script that is able to check only given labels ? Like i just need to check 1 campaign from 1 account, so i just put label on it and run?
You could do something similar to the code below.  First you would add the label to that account and then filter your MCC iterator using .withCondition
var accounts_iterator = MccApp.accounts().withCondition("LabelNames CONTAINS 'myLabel'").get();

Thanks,
Tyler Sidell
AdWords Scripts Team
Message has been deleted

Michał Fidelus

unread,
Jul 23, 2015, 3:13:28 AM7/23/15
to AdWords Scripts Forum
thanks for the answer on private message.


Hi Michal,

 

Thank you for supplying that information.  Please see my responses below:

1.  I was able to run the MCC version of the script within your MCC account, even with the keywords drop-down turned off.  I would suggest to make the following changes in order to get the script to run:

  • Make sure you are running the script from your MCC account
  • In cell C16, add the CIDs of the accounts that you want to check.  Right now there is an account there (#CID number#) that is not an account related to this particular MCC account.  Please make sure to use correct accounts.
  • Delete cells B17:D21
  • Delete content in B:1
  • Run script

2,Yes i know that i need to customize because i wont be able to check whole account anyway since it is so massive. I think we will be better with account level scripts anyway - 1 script for 1 account and when there is more then 20k urls to check more google accounts with more scripts to check that account selected by labels.

This solution should work.  If you are looking to run the script for only 1 account you may want to look at running it on the account level (under AdWordsApp).

 

3. So i guess the best way to divide campaigns on account would be using line with labels from 5. right? Where should i add that line in account level script?

I was able to get the MCC account to run the script so running the script and dividing by campaigns on the account level isn't necessary.  See #1

 

4, Any specific place i should add that line ? i'm really newbie :(

The default script has 

var response = UrlFetchApp.fetch(lastUrl, { muteHttpExceptions: true});

 

Modify that line to read:

var response = UrlFetchApp.fetch(lastUrl, { muteHttpExceptions: true, followRedirects: true});

 

 

6. Since i might have to use account level script and it doesn't seem to check sitelinks is there a way of adding that to account level script?

For the account level there would be some refactoring needed.  Please see #1 as you should be able to get this to properly run on the MCC account.

 

Thanks,

Tyler Sidell

AdWords Scripts Team




1. I did all that You mentioned but script still didint worked ;/ I think that the problem is with our MCK structure and script has some problems with that.

Our MCC structure is as follows.

Main MCC account:
                   >>MCC account #1
                             >>~50 accounts
                   >>MCC account #2
                             >>~30 accounts
                   >>MCC account #3
                             >>~10 accounts
 +3 non MCC accounts


When I am on MCC account #1 and I click on "bulk operations > scripts" menu I got bumped up to Main MCC account above. Thats why i tried using script to check one of those 3 non MCC account that are under Main MCC. I also tried putting 1 of those ~50 accounts from under MCC account #1 to cell C16 and it still doesnt work..

2. i think we still might need to drop MCC level script because on our Main MCC we got 400k of ads so we would need to make 20+ new google accounts with access and  scripts right ?
Thats why i think making account level script on each account would be easier.. since making 20+ new google accounts might be lot of hassle and putting scripts on each account might be simpler solution

3. If You could help me out anyway with single account level script labels. I still have to divide accounts somehow with more then 20k urls to be checked by 2 or more google accounts so it might be best solution. If You could just help me where i need to put that code from #5.

4. Thanks! Will check it out when i manage to make it work on default code.

6. As i mentioned in #3 I still might be forced to use single account level script version sooo any way of adding site link checking ? :P

Thank You for your help and testing so far :)

Michał F.

Tyler Sidell (AdWords Scripts Team)

unread,
Jul 23, 2015, 4:15:17 PM7/23/15
to AdWords Scripts Forum
Hi Michal,

1. When I am on MCC account #1 and I click on "bulk operations > scripts" menu I got bumped up to Main MCC account above. Thats why i tried using script to check one of those 3 non MCC account that are under Main MCC. I also tried putting 1 of those ~50 accounts from under MCC account #1 to cell C16 and it still doesnt work.
We have seen this issue with switching between accounts in the past.  If you want to get to the scripts of a sub-MCC:
  • Go to the Accounts tab (under main MCC)
  • Select the sub-MCC account from that list
  • Then navigate to scripts
In order to get the MCC script running correctly, remove lines 260, 291, and 322.  I believe these lines are the culprit.  I've removed them and was able to run the MCC script successfully from MCC account #1.
Basically remove any reference to this:
.withCondition("LabelNames CONTAINS_ANY ['u2-test']") 

2. i think we still might need to drop MCC level script because on our Main MCC we got 400k of ads so we would need to make 20+ new google accounts with access and  scripts right ?
Thats why i think making account level script on each account would be easier.. since making 20+ new google accounts might be lot of hassle and putting scripts on each account might be simpler solution
I would still recommend using the MCC level script over running this script on each individual account.  Making copies of the MCC spreadsheet and running each against a sample of the accounts would save time than creating a single script to copy into the 20+ different accounts.  It would be beneficial to get this script working properly on your MCC account, which we should be able to if you look at #1.

3. If You could help me out anyway with single account level script labels. I still have to divide accounts somehow with more then 20k urls to be checked by 2 or more google accounts so it might be best solution. If You could just help me where i need to put that code from #5.
On the single account level, this won't be necessary as the following function should handle this already.
function createLinkCheckerLabel() {
 
var labels = AdWordsApp.labels().withCondition(
     
"Name='" + LABEL_NAME + "'").get();
 
if (!labels.hasNext()) {
   
AdWordsApp.createLabel(LABEL_NAME,
       
"Managed by Link Checker, please don't modify!", '#60e020');
 
}
}

6. As i mentioned in #3 I still might be forced to use single account level script version sooo any way of adding site link checking ? :P
The MCC account level script should run if you remove the lines from the script that were outlined in question #1.  If you were to use the single account level script, you would have to modify both the spreadsheet and the script, and it won't be a simple task.

Modifications for the spreadsheet:
  • Add cell for "Check sitelinks"
  • Add cell for "Yes/No" dropdown
  • Set the named range to the drop-down cell
Modifications in the script:
  • Move over all code that references sitelinks
  • Modify the ranges to match up with the ranges set in the spreadsheet
Thanks,
Tyler Sidell
AdWords Scripts Team

Michał Fidelus

unread,
Jul 27, 2015, 8:25:51 AM7/27/15
to AdWords Scripts Forum
hello and sorry for late reponse as I've been busy lately,

We tested MCC level script and it seems to be working great with those changes from #1. We are trying it now scheduled to run every hour on quite big account with 13000 ads. So far everything looks good.

Ive noticed although that it seems to be checking urls in deleted Ad Groups on one of the earlier runs Ive tried and it started giving errrors since script wanted to add labels to deleted Ad groups. Its weird cuz i didnt noticed that on account that script is currently working on.. Maybe You got some idea why is this happening ?


Im also gonna see later if i can make it to check for redirects according to your instruction that U provided for me.


Really apreciate your help and patience with me :)

regards Michał F.

Thank You so much so far

Tyler Sidell (AdWords Scripts Team)

unread,
Jul 27, 2015, 4:05:23 PM7/27/15
to AdWords Scripts Forum
Hi Michal,

That's great news that you were able to get the script to run on the MCC account.  In order to avoid the issue where the script is adding labels to deleted Ad groups, you can apply a withCondition that only checks for enabled groups.

Example:
.withCondition("Status = ENABLED")

Thanks,
Tyler Sidell
AdWords Scripts Team

Michał Fidelus

unread,
Jul 28, 2015, 7:16:14 AM7/28/15
to AdWords Scripts Forum
hey again :)

Checking redirects doesnt seem to work unfortunately..  Ive added

followRedirects: true
 
to line 

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

 
and ended up with:


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


 in line #361 in the script named "url checker 1" on our MCC account. Do I need to add something else to make it work ?


Also i got no idea where i need to add line that makes script check only eneabled ads.. 

.withCondition("Status = ENABLED")



somewhere  along line #309 ?

damn im really newbie in this...


thank You again ;)

best Michał

Tyler Sidell (AdWords Scripts Team)

unread,
Jul 28, 2015, 4:31:44 PM7/28/15
to AdWords Scripts Forum
Hi Michal,

Glad that we're making progress.  As for the first question, I see that you've placed in the followRedirects parameter.  Have you tested with any specific redirects to make sure that it is not working?  If this solution is not working properly, another suggestion would be to modify the if statement directly under var response in the code.

Change
if (response.getResponseCode() < 300)

To
if (response.getResponseCode() < 300 || response.getResponseCode ==  302)


Also, to answer the second question, .withCondition("Status = ENABLED") can go around line 258:
var keywords = AdWordsApp.keywords()
       
.withCondition("FinalUrls STARTS_WITH_IGNORE_CASE 'h'")
       
.withCondition("LabelNames CONTAINS_NONE['" + settings.keywordsLabel +
             
"']")
       
.get();

Thanks,
Tyler Sidell
AdWords Scripts Team

Michał Fidelus

unread,
Jul 29, 2015, 8:59:06 AM7/29/15
to AdWords Scripts Forum
hey,
so ive added line 


.withCondition("Status = ENABLED")



to line #259 and it looks all like this

 
if (settings.checkKeywords) {
    var keywords = AdWordsApp.keywords()
        .withCondition("FinalUrls STARTS_WITH_IGNORE_CASE 'h'")
        .withCondition("LabelNames CONTAINS_NONE['" + settings.keywordsLabel +
        .withCondition("Status = ENABLED")
             "']")

 Hope its okay.


and about that line that checks for redirects i dont see that specific line in MCC version of script im using ive found it in single account level script.

so i couldnt modify 

if (response.getResponseCode() < 300)



to 

if (response.getResponseCode() < 300 || response.getResponseCode ==  302)



so ive just added it all right after

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

 in MCC version level script im using but i have a feeling it wont work ? ;)


best Michał

Tyler Sidell (AdWords Scripts Team)

unread,
Jul 29, 2015, 5:02:22 PM7/29/15
to AdWords Scripts Forum
Hi Michal,

I would modify your code just a bit.  I believe that what you supplied will throw an error.  Please modify it to:
if (settings.checkKeywords) {
var keywords = AdWordsApp.keywords()
.withCondition("FinalUrls STARTS_WITH_IGNORE_CASE 'h'")
.withCondition("LabelNames CONTAINS_NONE['" + settings.keywordsLabel + "']")

.withCondition("Status = ENABLED")
.get();
}

As for the redirect line, you can add wrap the accountSheet.appendRow function within that if statement:
if (response.getResponseCode() < 300 || response.getResponseCode ==  302) {
accountSheet
.appendRow(['', lastUrl,
                                status
, keyword.getCampaign().getName(),
                                keyword
.getAdGroup().getName(),
                                keyword
.getText(), '', '']);
}

Thanks,
Tyler Sidell
AdWords Scripts Team
...

Michał Fidelus

unread,
Jul 30, 2015, 3:42:26 AM7/30/15
to AdWords Scripts Forum
hey,

sooo yea im terrible at this.. Ive added/modified in both places and it gives an error now ..

ReferenceError: "settings" is not defined. (line 287)


Maybe You could just look at the script named "url checker 1"? Because I got a feeling it might take a while with my skills... ;)

Thank You in advance! :)

regards Mike

Tyler Sidell (AdWords Scripts Team)

unread,
Jul 30, 2015, 11:52:16 AM7/30/15
to AdWords Scripts Forum
Hi Michal,

I've noticed that your closing brackets are off.  You've closed the function that sets the settings variable thus why you are receiving that error.  Please check to make sure all of your brackets are properly closed.

Please remove the following lines:
Line 261: Closing bracket

You may also need to add an additional bracket at the end of all the code.

Thanks,
Tyler Sidell
AdWords Scripts Team

Reply all
Reply to author
Forward
0 new messages