Label Akun
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Buat label akun
function createAccountLabels(labelName) {
AdsManagerApp.createAccountLabel(labelName);
console.log("Label with text = '%s' created.", labelName);
}
Terapkan label akun ke beberapa akun
function applyAccountLabels(accountId1, accountId2, labelName) {
// You can modify this function to accept an array of IDs directly as well.
const accountIds = [accountId1, accountId2];
const accounts = AdsManagerApp.accounts().withIds(accountIds).get();
for (const account of accounts) {
account.applyLabel(labelName);
console.log('Label with text = "%s" applied to customer id %s.',
labelName, account.getCustomerId());
}
}
Hapus label akun dari beberapa akun
function removeLabelFromAccounts(accountId1, accountId2, labelName) {
const accountIds = [accountId1, accountId2];
var accounts = AdsManagerApp.accounts().withIds(accountIds).get();
for (const account of accounts) {
account.removeLabel(labelName);
console.log('Label with text = "%s" removed from customer id %s.',
labelName, account.getCustomerId());
}
}
Pilih akun menurut nama label
function selectAccountsByLabelName(labelName) {
const accountIterator = AdsManagerApp.accounts()
.withCondition(`LabelNames CONTAINS '${labelName}'`)
.get();
for (const account of accountIterator) {
const accountName = account.getName() ? account.getName() : '--';
console.log('%s,%s,%s,%s', account.getCustomerId(), accountName,
account.getTimeZone(), account.getCurrencyCode());
}
}
Pilih akun menurut ID label
function selectAccountsByLabelId(labelId) {
const label = AdsManagerApp.accountLabels().withIds([labelId]).get().next();
const accountIterator = label.accounts().get();
for (const account of accountIterator) {
const accountName = account.getName() ? account.getName() : '--';
console.log('%s,%s,%s,%s', account.getCustomerId(), accountName,
account.getTimeZone(), account.getCurrencyCode());
}
}
Ambil semua label akun
function getAllAccountLabels() {
const labelIterator = AdsManagerApp.accountLabels().get();
for (const label of labelIterator) {
console.log('Label with id = %s and text = %s was found.',
label.getId().toFixed(0), label.getName());
}
}
Ambil label akun menurut namanya
function getLabelByName(labelName) {
const labelIterator = AdsManagerApp.accountLabels()
.withCondition(`label.name CONTAINS '${labelName}'`)
.get();
for (const label of labelIterator) {
console.log(`Label with id = ${label.getId().toFixed(0)} ` +
`and text = ${label.getName()} was found.`);
}
}
Ambil label akun menurut ID-nya
function getLabelById(labelId) {
const labelIterator = AdsManagerApp.accountLabels()
.withIds([labelId])
.get();
for (const label of labelIterator) {
console.log("Label with id = %s and text = '%s' was found.",
label.getId().toFixed(0), label.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-08-21 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-08-21 UTC."],[[["This script provides functions for managing account labels in Google Ads Manager, including creating, applying, and removing labels from accounts."],["You can use it to select specific accounts based on label names or IDs for targeted management."],["The script enables retrieving information about all existing account labels or specific labels by name or ID."],["These functionalities streamline account organization and reporting within your Google Ads Manager hierarchy."],["Provided examples demonstrate how to perform these tasks with simple, clear, and well-documented code snippets."]]],[]]