임시 캠페인 및 실험

임시 캠페인 만들기

function createDraft(campaignName, newDraftName) {
  const campaign = AdsApp.campaigns()
      .withCondition(`campaign.name = '${campaignName}'`)
      .get()
      .next();

  var draftBuilder = campaign.newDraftBuilder()
      .withName(newDraftName)
      .build();

  var draft = draftBuilder.getResult();
}

임시 캠페인 가져오기

function getDrafts() {
  // Get all drafts.
  const drafts = AdsApp.drafts().get();

  console.log(drafts.totalNumEntities());

  for (const draft of drafts) {
    console.log("Draft: " + draft.getName());
  }

  // Get a specific draft.
  const campaignIterator = AdsApp.drafts()
      .withCondition("campaign_draft.name = 'INSERT_DRAFT_NAME'")
      .get();

  for (const campaign of campaignIterator) {
    console.log(campaign.getName());
  }
}

실험 만들기

function createExperiment(draftName, newExperimentName) {
  const draft = AdsApp.drafts()
      .withCondition(`campaign_draft.name = '${draftName}'`)
      .get()
      .next();

  var experimentBuilder = draft.newExperimentBuilder();

  experimentBuilder.withName(newExperimentName)
      .withTrafficSplitPercent(50)
      .startBuilding();
}

실험 가져오기

function getExperiments() {
  // Get all experiments.
  var exps = AdsApp.experiments().get();

  console.log(exps.totalNumEntities());

  while (exps.hasNext()) {
    var exp = exps.next();
    console.log("Experiment: " + exp.getName());
  }

  // Get specific experiment.
  var campaignIterator = AdsApp.experiments()
      .withCondition("Name = 'INSERT_EXPERIMENT_NAME'")
      .get();

  while (campaignIterator.hasNext()) {
    console.log(campaignIterator.next().getName());
  }
}