Negative Keyword Conflicts - Finding the negative keyword

1,263 views
Skip to first unread message

Mads Ellegård

unread,
Feb 15, 2017, 8:41:24 AM2/15/17
to AdWords Scripts Forum
Hi, 

Im using this script.

Its working fine, but I have one problem. A lot of my keywords are organized in negative keywords list with lots of keywords. So its hard for me to figure out exactly where the keywords thats causing the conflict is listed. 

Can anyone help with that?

Also I'm interested in knowing if I, in the spreadsheet, can change the account id to the account name?

Thanks!
Mads



Anthony Madrigal

unread,
Feb 15, 2017, 10:59:16 AM2/15/17
to AdWords Scripts Forum
Hi Mads,

You can use the function getNegativeKeywordList in the SharedNegativeKeyword object to get the Negative Keyword List where the keyword is located.

To get the account name instead of Id, you can change the var hasConflicts to 
var hasConflicts = outputConflicts(spreadsheet,
   
AdWordsApp.currentAccount().getName(), conflicts);

Cheers,
Anthony
AdWords Scripts Team

Mads Ellegård

unread,
Feb 17, 2017, 2:55:09 AM2/17/17
to AdWords Scripts Forum
Hi Anthony, 

I changed the output to this but it doesnt seem to be working?

  for (var i = 0; i < results.length; i++) {
    if (!results[i].getError()) {
        var hasConflicts = outputConflicts(spreadsheet, AdWordsApp.currentAccount().getName(), conflicts,
          JSON.parse(results[i].getReturnValue())) || hasConflicts;
    } else {

Also, could you elaborate on how you would install the "getNegativeKeywordList"? I'ver tried figuring this stuff out myself, but it seems a bit too technical. 

Thanks!
Mads 

Anthony Madrigal

unread,
Feb 17, 2017, 9:33:50 AM2/17/17
to AdWords Scripts Forum
Hi Mads,

Since you are using the MCC version of the script, you will want to change results[i].getCustomerId() to results[i].getName() in the two instances they appear in the original code.

To implement getNegativeKeywordList, you can use this script separately to get what Negative Keyword List each of your negative keywords appear in. This script is implemented on the MCC level.
function main() {
 
var accountSelector = MccApp.accounts();
  accountSelector
.executeInParallel('processAccount', null);
}

function processAccount() {
 
var account = AdWordsApp.currentAccount();
 
 
var NKLI = AdWordsApp.negativeKeywordLists().get();
 
while(NKLI.hasNext()){
   
var NKL = NKLI.next();
   
var NKI = NKL.negativeKeywords().get();
   
while(NKI.hasNext()){
     
var NK = NKI.next();
     
Logger.log(NK.getText() + " is in " + NKL.getName() + " from " + account.getCustomerId() + ": " + account.getName());
   
}
 
}
}


Cheers,
Anthony
AdWords Scripts Team

Mads Ellegård

unread,
Apr 10, 2017, 3:25:55 AM4/10/17
to AdWords Scripts Forum
Hi Anthony, 

Thanks. I haven't answered because I wasnt quite sure how to implement your script. 

I dont get how it helps to implement it separately? Do you mean as a whole new script? Or should I add it to the existing lines of code?

When I replace then i get this error:

TypeError: Cannot find function getName in object ExecutionResult. (line 120)

The strings look like this:

function processResults(results) {
  var hasConflicts = false;
  var spreadsheet = SpreadsheetApp.openByUrl(CONFIG.SPREADSHEET_URL);
  if (CONFIG.COPY_SPREADSHEET) {
    spreadsheet = spreadsheet.copy('Negative Keyword Conflicts');
  }
  initializeSpreadsheet(spreadsheet);

  for (var i = 0; i < results.length; i++) {
    if (!results[i].getError()) {
      hasConflicts = outputConflicts(spreadsheet, results[i].getName(),

          JSON.parse(results[i].getReturnValue())) || hasConflicts;
    } else {
      Logger.log('Processing for ' + results[i].getName() + ' failed.');
    }
  }
  if (hasConflicts && CONFIG.RECIPIENT_EMAILS) {
    sendEmail(spreadsheet);
  }
}

Mads

Anthony Madrigal

unread,
Apr 10, 2017, 9:36:43 AM4/10/17
to AdWords Scripts Forum
Hi Mads,

The script that I provided previously is a new script that you can use on the MCC level that will find the negative keywords in your negative lists and return which client account it is under.

The change results[i].getCustomerId() to results[i].getName() will be implemented in the Negative Keyword Conflicts script.

If you are still facing issues please reply privately to author your CID and script name so I can take a look.

Regards,
Anthony
AdWords Scripts Team
Reply all
Reply to author
Forward
0 new messages