Monday, March 11, 2013

Merge Multiple Campaigns Together For Enhanced Campaigns Migration

UPDATE 2013-04-14: Check Merge Labels from Multiple Campaigns for some help on merging labels.

Everyone is getting ready for Enhanced Campaigns and for a lot of people, that means finding an easy way to merge multiple campaigns into a single campaign. You may have a campaign for desktop traffic and one for tablet, or maybe one for each major mobile platform.

Well the beauty and the pain of Enhanced Campaigns is that you can do more with less. I haven't found a great way to easily merge multiple campaigns into one, so I made my own. All you need to do is specify a destination campaign where you want all the keywords, adgroups, and ads to end up and the set of campaigns you want to copy from. This script will pause any keyword and ad it manages to move over so you can see results and make sure everything is set up properly before deleting the old campaigns.


// Merge Multiple Campaigns Together
// Created By: Russ Savage
function main() {
  var DESTINATION_CAMPAIGN_NAME = "dest_camp_name";
  var ORIGIN_CAMPAIGN_NAMES = ["to_merge_camp_name_1","to_merge_camp_name_2"/*,...*/];
  var DEFAULT_KW_BID = 0.01; //used in case we can't get the origin kw bid
  //build a list of adgroups in the original 
  var dest_adgroups = [];
  var ag_iter = AdWordsApp.adGroups()
    .withCondition("CampaignName = '"+DESTINATION_CAMPAIGN_NAME+"'")
  while(ag_iter.hasNext()) {
  var dest_camp;
  if(dest_adgroups.length > 0) {
     dest_camp = dest_adgroups[0].getCampaign();
  for(var i in ORIGIN_CAMPAIGN_NAMES) {
    var camp_name = ORIGIN_CAMPAIGN_NAMES[i];
    var kw_iter = AdWordsApp.keywords()
      .withCondition("CampaignName = '"+camp_name+"'")
    while(kw_iter.hasNext()) {
      var kw =;
      var dest_adgroup = _find_adgroup(dest_adgroups,kw.getAdGroup());
      if(!dest_adgroup) {
        dest_adgroup = dest_camp.newAdGroupBuilder()
          .withStatus((kw.getAdGroup().isPaused()) ? "PAUSED" : "ENABLED")
        //now we move all the ads over
        var ad_iter = kw.getAdGroup().ads().get();
        while(ad_iter.hasNext()) {
          var ad =;
            { isMobilePreferred : ad.isMobilePreferred() }
      var max_cpc = kw.getMaxCpc() || DEFAULT_KW_BID;
      var dest_url = kw.getDestinationUrl() || "";
      var kw_text = kw.getText();


  function _find_adgroup(ag_list,ag) {
    for(var i in ag_list) {
      if(ag_list[i].getName() == ag.getName()) {
        return ag_list[i];
    return null;


  1. Hello Russell,

    Will this maintain the keyword/ad history?

    1. Hi Gonzitz, Unfortunately this will not maintain ad or keyword history. In AdWords, you cannot edit a keyword or ad once it is created. Anytime you make a change, it destroys the old ad and creates a new one (with a new id).

      If you are using any 3rd party tools, they are keeping track of those elements outside of AdWords.

      Your best option would be to use labels to accomplish this. Again, unfortunately, adwords scripts do not allow you to add labels to keywords at the time they are created (i added this as a feature request.

      Since this script only pauses keywords and adgroups, we should be able to create another script that will copy the labels over to the new campaign from the old one. If that is something you might find useful, let me know and I will put something together.


  2. Oh man - I would LOVE a script that would copy over the labels, Russ!! Just stumbled on your site and I love it. I'll share the word and give you all the credit :)

  3. This is a potentially good site. But I want some updates like here

  4. hey there, the best collection of jewelry is now available, different kinds of necklaces and earnings with best prices for Christmas, beautiful necklace for women that you love, I'm sure you'll love them

  5. Your blogs are great.Are you also searching for Nursing Writing Services? we are the best solution for you. We are best known for delivering nursing writing services to students without having to break the bank.

  6. Really very useful and Informative information are provided here. Thank you so much for writing keep up like this. [pii_email_84e9c709276f599ab1e7]

  7. This comment has been removed by the author.