アカウントのラベル
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
アカウント ラベルを作成
function createAccountLabels(labelName) {
AdsManagerApp.createAccountLabel(labelName);
console.log("Label with text = '%s' created.", labelName);
}
複数のアカウントに 1 つのアカウント ラベルを適用
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());
}
}
複数のアカウントからアカウント ラベルを削除
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());
}
}
ラベル名を指定してアカウントを選択
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());
}
}
ラベル ID を指定してアカウントを選択
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());
}
}
すべてのアカウント ラベルを取得
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());
}
}
名前を指定してアカウント ラベルを取得
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.`);
}
}
ID を指定してアカウント ラベルを取得
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());
}
}
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-09-11 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-09-11 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."]]],[]]