How to group the same keywords from differents campaigns ?

105 views
Skip to first unread message

Éric NIAKISSA

unread,
May 4, 2012, 3:04:18 PM5/4/12
to adwords...@googlegroups.com
Hello,
 
I would like to log the best "unique" keyword or dedupe the same keywords
 
Example : Log 20 keywords that had the most impressions yesterday
 
This is the actual result :
 
Keyword: impressions
Shoes : 1275 (Campaign #1 "Alabama")
Boots : 849 (Campaign #4 "Arkansas")
Shoes : 673 (Campaign #2 "Alaska")
Boots : 582 (Campaign #1 "Alabama")
Shoes : 405 (Campaign #3 "Arizona")
etc.
 
This is what i would like :
Keyword: impressions
1) Shoes : 2353
2) Boots : 1431
etc.

Eric Koleda

unread,
May 4, 2012, 3:38:23 PM5/4/12
to adwords...@googlegroups.com
Hi Eric,

That's a great idea for a script.  There's isn't built-in support to merge together keywords in different ad groups and campaigns, but with some creative JavaScript coding you should be able to achieve this result.  A simple solution is to keep track of these keywords using a JavaScript map (aka object).  The map keys would be the keyword text and the values would be the total number of impressions.  Here's a sample I wrote:

function main() {
 
var map = {};
 
var keywordsIter = AdWordsApp.keywords()
     
.forDateRange('LAST_WEEK')
     
.orderBy('Impressions DESC')
     
.withLimit(10).get();
 
 
// Build the map.
 
while (keywordsIter.hasNext()) {
   
var keyword = keywordsIter.next();
   
var text = keyword.getText();
   
var impressions = keyword.getStatsFor('LAST_WEEK').getImpressions();
   
if (map[text]) {
     
// Add to the total.
      map
[text] += impressions;
   
} else {
     
// Add a new entry to the map.
      map
[text] = impressions;
   
}
 
}
 
 
// Log the results.
 
for (var text in map) {
   
var impressions = map[text];
   
Logger.log(text + ' = ' + impressions);
 
}
}

Because we are merging together keywords however the total number of results at the end may be less than the 10 that we specified in the "withLimit()" function.  Additionally, printing out the map in this way doesn't guarantee that the results are in the correct order.  I hope that is enough to get you started though, and let us know if you have other questions.

Best,
- Eric Koleda, AdWords Scripts Team

Éric NIAKISSA

unread,
May 4, 2012, 4:01:56 PM5/4/12
to adwords...@googlegroups.com
Many Thanks Éric  :-)
 
It works ! Actually i have to sort keywords in the correct order.
 
For my information, since how long Adwords Scripts is available ?

Eric Koleda

unread,
May 4, 2012, 5:03:02 PM5/4/12
to adwords...@googlegroups.com
Hi Eric,

We just recently made AdWords Scripts available to a select set of advertisers, and we hope to bring it to everyone soon.

Best,
- Eric

Robert Chapman

unread,
May 18, 2012, 6:39:54 AM5/18/12
to adwords...@googlegroups.com
Some of the behaviour of the original code suggests to me it would be possible to use javascript to find all the duplicate keywords within an account....I wish my skills were better with this as I'd code it myself!

Eric Koleda

unread,
May 18, 2012, 10:08:49 AM5/18/12
to adwords...@googlegroups.com
Hi Robert,

You could certainly use AdWords Scripts to locate duplicate keywords, and that code should get you on the right track. If you'd like to start learning JavaScript I'd recommend http://www.codecademy.com/.

Best,
- Eric
Reply all
Reply to author
Forward
0 new messages