Duplicate Keywords in Campaign Script not working

30 views
Skip to first unread message

Aravin

unread,
Oct 18, 2017, 9:06:05 PM10/18/17
to AdWords Scripts Forum
Hi Mr Thea, this script which u provided me does successfully runs but does not output the duplicate keywords in the log, i checked with my colleague and he said certain campaigns have duplicates in the account but using this script for all the campaigns in the account it does not show any duplicates. May i know what to do to resolve this and display the relevant keywords for the appropriate campaigns? Thank you very much Sir and have a good day ahead of you.

Cheers Sir,
Aravin

function
 main() {
  
var kwText = [];

  
var campaignSelector = AdWordsApp.campaigns();
  
  
var campaignIterator = campaignSelector.get();
  
while (campaignIterator.hasNext()) {
    
var campaign = campaignIterator.next();
    
Logger.log("Campaign Name: %s",campaign.getName()); //logs the campaign name

    
Logger.log("Duplicate keywords:");
    
var keywordSelector = campaign.keywords();
    
    
var keywordIterator = keywordSelector.get(); //gets for keywords

    
while (keywordIterator.hasNext()) {
      
var keyword = keywordIterator.next();

      kwText
.push(keyword.getText()); //stores keywords in array
    
}
    kwText
.sort(); //sorts the keywords alphabetically
    
for (var i = 0; i < kwText.length - 1; i++) { //iterates until array length > 0
      
if (kwText[+ 1] == kwText[i]) { //compares keyword[i] and keyword[i+1]
      
Logger.log(kwText[i]); //logs duplicates
      
}
    
}
    
Logger.log('---------------------------'); //divider
    kwText
=[]; //clears array
  
}
}

Thea Vega (AdWords Scripts Team)

unread,
Oct 19, 2017, 2:48:04 AM10/19/17
to AdWords Scripts Forum
Hi Aravin,

I tried the script on my end and it worked perfectly fine, logging all duplicate keywords per campaign on a single account. 

With this, here are the possible reasons that there are no logs on your end.
  • If you are previewing this on a manager account, although the preview will be successful, there will be no logs since the script was designed to perform on a single/client account. Could you confirm that you are using the script on a single/client account?
  • There are no duplicate keywords per campaign. The script outputs all duplicate keywords per campaign. An example would be if you preview this script on your client account named Client Account 1. Under Client Account 1, there are 2 campaigns named campaign 1 and campaign 2 respectively. Under campaign 1, there are 2 keywords on different ad groups named keyword 1. On campaign 2, there are 2 keywords which is keyword 2 and also keyword 3. If the script will be previewed, the result would be "Campaign Name: campaign 1 | Duplicate Keywords: keyword 1 | Campaign Name: campaign 2 | Duplicate Keywords: ". As you can see, there will be no duplicate keywords listed on campaign 2 since there are no duplicate keywords inside that particular campaign
If you think these aren't the cases, do provide me your CID and script, as well as more information (i.e. campaign name and specific duplicate keywords that should have been logged by the script) via Reply privately to author so I can further investigate.

Thanks,
Thea
AdWords Scripts Team

Aravin

unread,
Oct 20, 2017, 2:06:01 AM10/20/17
to AdWords Scripts Forum
Hi Mr Thea,using the customer id can u figure out details such as the type of my account and the campaigns as such? Cos i am using a test account given by my colleague and i am unsure of how to navigate myself around. Thank you so much sir and have a nice day.

Cheers Sir,
Aravin

Aravin

unread,
Oct 20, 2017, 2:59:57 AM10/20/17
to AdWords Scripts Forum
Just to add on Mr Thea, when i previewed the script it was done successfully, that means the script is running but for all of the campaigns it is not showing the duplicate keywords, just wanted to clear that out sir. Thank you for your time.

Cheers Sir,
Aravin

Thea Vega (AdWords Scripts Team)

unread,
Oct 20, 2017, 3:37:28 AM10/20/17
to AdWords Scripts Forum
Hi Aravin,

In AdWords Scripts, you can use the customer ID as filter for the campaigns but you can't use it to know the account type. As for my understanding, you want to know if an account is a manager or a client account. To know if the account you're on is a manager or a client account, see below.

Old Interface:
- Do look at the upper left part of your window and locate your account name and CID. The account type will be shown (either Manager or Client Account). See attached photo (account type old interface.png) for more details.
New Interface:
- Do look at the upper left part of your window and locate your account name and CID. To know if it is a manager account, the upper part of your window should list all client accounts (See account type new interface manager account.png). For client accounts, all campaigns will be listed on the upper part of your window. (See account type new interface client account.png)
 
I suggest for you to read our documentation on how to get started using AdWords Scripts and to open up a new thread for new topics for better tracking. 

As previously mentioned, the script works fine on my end. A possible reason why there are no logs is because you are running the script on a Manager level. Another reason would be there are no duplicate keywords per campaign. Please refer to my previous reply as I explained these briefly there. Also, as previously mentioned, do give me your CID and script name, as well as more information (i.e. campaign name and specific duplicate keywords that should have been logged by the script) via Reply privately to author since it seems that you are still experiencing issues.
account type old interface.png
account type new interface manager account.png
account type new interface client account.png

Aravin

unread,
Oct 20, 2017, 3:46:45 AM10/20/17
to AdWords Scripts Forum
Hi Mr Thea, attached is the screenshot on how my page looks like and from this i can deduce that it is a client account but i just would like you to help me verify it and sure sir will create a new thread for other questions for better tracking and will pass you my customer id and the script privately. Thank you so much Sir.

Cheers Sir,
Aravin
Capture.PNG
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages