Draft and Experiment Keyword Bids Change

53 views
Skip to first unread message

Cyrille Barrot

unread,
Dec 3, 2018, 11:34:59 AM12/3/18
to Google Ads Scripts Forum
Hi Everyone,

I'm running a test using AdWords draft and Experiments and I would like to keep search bids between the experiment and normal campaigns similar. As I'm using an 3rd party bid management platform (Marin) currently the bids are applied separately and differently on the experiment vs the normal keywords on a daily basis.
So would you have a script or the base of a script that could run everyday and copy the search bids of my normal keywords and apply them to my experiment keywords?

Many thanks in advance for your help,

Cyrille

Vincent Racaza (AdWords Scripts Team)

unread,
Dec 3, 2018, 5:56:09 PM12/3/18
to Google Ads Scripts Forum
Hi Cyrille,

I'm afraid that there are no readily available scripts that can copy the bidding of a keyword and apply it to the bidding of an experiment keyword. However, to get you started on creating the script based on your requirements, you may try to follow the instruction provided below.

1.) Implement the keywords iterator to get all the keywords and its data.
2.) Use the getCpc to get the bidding of the keyword and store it in a variable.
3.) Then, implement the experiment iterator.
4.) Inside the experiment iterator, implement the getExperimentCampaign and keywords iterator.
5.) Lastly, set the bid to the experiment keywords by using the setCpc method.

Please let me know if you have further questions/clarifications.

Regards,
Vincent
Google Ads Scripts Team

Cyrille Barrot

unread,
Dec 10, 2018, 6:23:50 AM12/10/18
to Google Ads Scripts Forum
Hi Vincent,

Thanks for your help!
I'm going to try to write the script base on your recommendation, and probably I will come back to you if i get stuck somewhere.

Kind Regards,

Cyrille

Cyrille Barrot

unread,
Dec 10, 2018, 10:13:08 AM12/10/18
to Google Ads Scripts Forum
Hi Vincent,

So I'm a bit stuck with the script so far as I didn't really get from step 3, how the script is supposed to match the keyword max CPC to my keywords in the experiment campaign.
I tried with an if function but it doesn't seem to work. Please see the script below, could you give me your feedback on how to make it work


--------------------------------------------------------------

function main() {
  
  var keywordSelector = AdsApp
     .keywords()
  .withCondition("CampaignName CONTAINS 'XXX'")
  .withCondition("CampaignName DOES_NOT_CONTAIN 'Draft'")
     .forDateRange("TODAY")
     .orderBy("Id");

 var keywordIterator = keywordSelector.get();
 while (keywordIterator.hasNext()) {
   var keyword = keywordIterator.next();
   
   var cpc = keyword.bidding().getCpc();
 
   
   var experimentSelector = AdsApp.experiments()
     .withCondition("ExperimentCampaignId = XXX")
     .orderBy("Id");

 var experimentIterator = experimentSelector.get();
 while (experimentIterator.hasNext()) {
   var experiment = experimentIterator.next();
   
   var expKeywordIter = experiment.getExperimentCampaign().keywords().orderBy("Id").get();
   
   while (expKeywordIter.hasNext()){
     var expKeyword = expKeywordIter.next()
     if (keyword.getText() == expKeyword.getText()){
        expKeyword.bidding().setCpc(cpc)
        var textLog = "Keyword :" + keyword.getText() + " cpc: " + cpc + " expKeyword: " + expKeyword.getText() + "cpc: " + expKeyword.bidding().setCpc(cpc);
    Logger.log(textLog)
   }
   }
   }
 }
   
 };

-----------------------------------------------------------------------------------------------------------

Anthony Madrigal

unread,
Dec 10, 2018, 4:32:09 PM12/10/18
to Google Ads Scripts Forum
Hi Cyrille,

Could you confirm if my understanding is correct for this line "how the script is supposed to match the keyword max CPC to my keywords in the experiment campaign."? Could you confirm if what you meant is you want to get the bidding of a certain keyword, then set the bidding of this to a certain keyword in the experiment campaign? For example, the script will get the bidding of keyword A then, the bidding of this keyword will only set to keyword B in the experiment campaign.

If this is the scenario, I suggest that the name of the keyword in the campaign (where you will get the bidding) would be the same with keyword in the experiment campaign (where you will set the bidding) so that the modified script below will work well. For example, the keyword name in the regular campaign where you will get the bidding is keywordA and the name of the keyword in the experiment campaign will be keywordA as well.

function main() {
 
 
var campATextBid = [];

 
 
var keywordSelector = AdsApp
   
.keywords()

 
.withCondition("CampaignName CONTAINS 'INSERT_CAMPAIGN_NAME_HERE'")

   
.withCondition("CampaignName DOES_NOT_CONTAIN 'Draft'")
   
.forDateRange("TODAY")
   
.orderBy("Id")

   
.get();
 
while (keywordSelector.hasNext()) {
   
var keyword = keywordSelector.next();
   
var kwTextBid = [];
    kwTextBid
.push(keyword.getText());
    kwTextBid
.push(keyword.bidding().getCpc());
    campATextBid
.push(kwTextBid);
 
}
 
 
var experimentSelector = AdsApp.experiments().withCondition("ExperimentCampaignId = 'INSERT_EXPERIMENT_CAMPAIGN_ID'").get();
 
while (experimentSelector.hasNext()) {
     
var experiment = experimentSelector.next();
     
var campaign = experiment.getExperimentCampaign();        
       
for (i = 0; i < campATextBid.length; i++) {
           
var keywords = campaign.keywords().withCondition('Text = "' + campATextBid[i][0] + '"').get();
           
while (keywords.hasNext()) {
               
var keyword = keywords.next();
                keyword
.bidding().setCpc(campATextBid[i][1]);
               
Logger.log("Keyword:" + campATextBid[i][0] + ", SetCPC:" + campATextBid[i][1]);
           
}
     
}
 
}
}

You may also try to click the PREVIEW button to test the modified script. Please let me know if you encounter any issue or you have further questions/clarifications.

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