علامات الحساب
تنظيم صفحاتك في مجموعات يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
إنشاء تصنيف حساب
function createAccountLabels(labelName) { AdsManagerApp.createAccountLabel(labelName); console.log("Label with text = '%s' created.", labelName); }
تطبيق تصنيف حساب على حسابات متعددة
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()); } }
اختيار حساب حسب رقم تعريف التصنيف
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.`); } }
استرجاع تصنيفات حسابات حسب أرقام التعريف المتعلقة بها
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()); } }
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-08-21 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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"]],["تاريخ التعديل الأخير: 2025-08-21 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eThis script provides functions for managing account labels in Google Ads Manager, including creating, applying, and removing labels from accounts.\u003c/p\u003e\n"],["\u003cp\u003eYou can use it to select specific accounts based on label names or IDs for targeted management.\u003c/p\u003e\n"],["\u003cp\u003eThe script enables retrieving information about all existing account labels or specific labels by name or ID.\u003c/p\u003e\n"],["\u003cp\u003eThese functionalities streamline account organization and reporting within your Google Ads Manager hierarchy.\u003c/p\u003e\n"],["\u003cp\u003eProvided examples demonstrate how to perform these tasks with simple, clear, and well-documented code snippets.\u003c/p\u003e\n"]]],[],null,["Create an account label \n\n```text\nfunction createAccountLabels(labelName) {\n AdsManagerApp.createAccountLabel(labelName);\n console.log(\"Label with text = '%s' created.\", labelName);\n}\n```\n\nApply an account label to multiple accounts \n\n```gdscript\nfunction applyAccountLabels(accountId1, accountId2, labelName) {\n // You can modify this function to accept an array of IDs directly as well.\n const accountIds = [accountId1, accountId2];\n\n const accounts = AdsManagerApp.accounts().withIds(accountIds).get();\n for (const account of accounts) {\n account.applyLabel(labelName);\n\n console.log('Label with text = \"%s\" applied to customer id %s.',\n labelName, account.getCustomerId());\n }\n}\n```\n\nRemove an account label from multiple accounts \n\n```gdscript\nfunction removeLabelFromAccounts(accountId1, accountId2, labelName) {\n const accountIds = [accountId1, accountId2];\n\n var accounts = AdsManagerApp.accounts().withIds(accountIds).get();\n for (const account of accounts) {\n account.removeLabel(labelName);\n\n console.log('Label with text = \"%s\" removed from customer id %s.',\n labelName, account.getCustomerId());\n }\n}\n```\n\nSelect an account by label name \n\n```gdscript\nfunction selectAccountsByLabelName(labelName) {\n const accountIterator = AdsManagerApp.accounts()\n .withCondition(`LabelNames CONTAINS '${labelName}'`)\n .get();\n\n for (const account of accountIterator) {\n const accountName = account.getName() ? account.getName() : '--';\n console.log('%s,%s,%s,%s', account.getCustomerId(), accountName,\n account.getTimeZone(), account.getCurrencyCode());\n }\n}\n```\n\nSelect an account by label ID \n\n```transact-sql\nfunction selectAccountsByLabelId(labelId) {\n const label = AdsManagerApp.accountLabels().withIds([labelId]).get().next();\n const accountIterator = label.accounts().get();\n\n for (const account of accountIterator) {\n const accountName = account.getName() ? account.getName() : '--';\n console.log('%s,%s,%s,%s', account.getCustomerId(), accountName,\n account.getTimeZone(), account.getCurrencyCode());\n }\n}\n```\n\nRetrieve all account labels \n\n```gdscript\nfunction getAllAccountLabels() {\n const labelIterator = AdsManagerApp.accountLabels().get();\n for (const label of labelIterator) {\n console.log('Label with id = %s and text = %s was found.',\n label.getId().toFixed(0), label.getName());\n }\n}\n```\n\nRetrieve an account label by its name \n\n```gdscript\nfunction getLabelByName(labelName) {\n const labelIterator = AdsManagerApp.accountLabels()\n .withCondition(`label.name CONTAINS '${labelName}'`)\n .get();\n\n for (const label of labelIterator) {\n console.log(`Label with id = ${label.getId().toFixed(0)} ` +\n `and text = ${label.getName()} was found.`);\n }\n}\n```\n\nRetrieve account labels by their IDs \n\n```transact-sql\nfunction getLabelById(labelId) {\n const labelIterator = AdsManagerApp.accountLabels()\n .withIds([labelId])\n .get();\n\n for (const label of labelIterator) {\n console.log(\"Label with id = %s and text = '%s' was found.\",\n label.getId().toFixed(0), label.getName());\n }\n}\n```"]]