Draf dan Eksperimen
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Membuat draf kampanye
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();
}
Mendapatkan draf kampanye
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());
}
}
Membuat eksperimen
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();
}
Mendapatkan eksperimen
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());
}
}
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2024-09-10 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2024-09-10 UTC."],[[["This script provides functions for managing Google Ads drafts and experiments, including creating, retrieving, and interacting with them."],["`createDraft` function enables the creation of a new draft campaign from an existing campaign using their respective names."],["`getDrafts` function retrieves and displays either all existing drafts or a specific draft based on its name."],["`createExperiment` function initiates a new experiment based on a selected draft, assigning it a name and traffic split percentage."],["`getExperiments` function lists all available experiments or a specific one using its name, aiding in experiment monitoring and management."]]],[]]