تبديل الاستراتيجية
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
سيتم تقديم هذا الدليل لإنشاء نموذج مطابق تمامًا لأدلة "حملات الأداء الأفضل" الحالية، والتي تفترض أنّك ستنشئ الحملة بأكملها في طلب واحد، بدلاً من إنشاء كل عنصر على حدة في طلبات منفصلة. وهذا يعني أنّه عليك استخدام
معرّفات مؤقتة لربط
الموارد ببعضها البعض، لأنّك لن تعرف أسماء الموارد الكاملة إلا بعد
الحصول على استجابة واجهة برمجة التطبيقات.
لإجراء ذلك، عليك كتابة بعض الرموز البرمجية للتأكّد من عدم إنشاء أي معرّفات مؤقتة مكرّرة:
let nextId = -1;
function getNextTempId() {
const ret = nextId;
nextId -= 1;
return ret;
}
سيؤدي كل استدعاء متتالٍ للدالة getNextTempId
إلى عرض رقم أقل من الرقم السابق بمقدار واحد. بما أنّ جميع المعرّفات المؤقتة يجب أن تكون سالبة، ابدأ بالرقم -1.
بعد إعداد ذلك، يمكنك الآن إنشاء مصفوفة لتضمين جميع العمليات:
const operations = [];
ستحتاج بشكل متكرّر إلى رقم تعريف العميل الذي تنشئ الحملة في حسابه، لأنّه مطلوب في كل اسم مورد.
const customerId = AdsApp.currentAccount().getCustomerId();
في كل مرة تريد فيها إنشاء عملية جديدة، ستستخدم المعرّف المؤقت التالي في اسم المورد، حتى تتمكّن من الرجوع إلى هذا العنصر لاحقًا، وإدراج العنصر الذي تم إنشاؤه في المصفوفة:
const newOperation = {
[OPERATION_TYPE_VARIES]: {
create: {
resourceName: `customers/${customerId}/[EXACT_PATH_VARIES]/${getNextTempId()}`
// Other fields, relevant to the resource being created.
}
}
}
operations.push(newOperation);
يمكنك الاطّلاع على مزيد من المعلومات ومشاهدة مثال على عملية في مستندات Google Ads API REST mutate.
بعد إنشاء جميع العمليات، نفِّذها في دفعة واحدة:
AdsApp.mutateAll(operations);
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-08-27 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-27 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eThis guide provides instructions on creating Google Ads Performance Max campaigns using the Google Ads API with a single atomic request, as opposed to creating each entity individually.\u003c/p\u003e\n"],["\u003cp\u003eTo link resources within the single request, temporary IDs are utilized and assigned with a function ensuring unique negative values for each.\u003c/p\u003e\n"],["\u003cp\u003eThe guide involves constructing an array of operations, where each operation represents the creation of a specific campaign component.\u003c/p\u003e\n"],["\u003cp\u003eAfter defining all campaign elements and their relationships through the operations array, the entire campaign structure is created by executing a single batch mutation request via \u003ccode\u003eAdsApp.mutateAll(operations)\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Mutate Strategy\n\nThis guide will be presented to construct an exact analog to the existing\nPerformance Max guides, which assume that you will be creating the entire\ncampaign in a single atomic request, rather than creating each entity one at a\ntime in separate requests. This means that you'll need to use\n[temporary IDs](/google-ads/api/docs/batch-processing/temporary-ids) to link\nresources to each other, since you won't know the full resource names until you\nget the API response.\n\nTo do this, you'll have to write some code to ensure that you don't create any\nduplicate temp IDs: \n\n let nextId = -1;\n\n function getNextTempId() {\n const ret = nextId;\n nextId -= 1;\n return ret;\n }\n\nEach successive call to `getNextTempId` will return a number one less than the\nprevious. Since all temp IDs must be negative, start at -1.\n\nWith this in place, you can now create an array to hold all the operations: \n\n const operations = [];\n\nYou will frequently need the customer ID for the customer you're making the\ncampaign in, since it's required in every resource name. \n\n const customerId = AdsApp.currentAccount().getCustomerId();\n\nEach time you want to create a new operation, you will use the next temp ID in\nthe resource name, so that you can reference this object later, and insert the\nobject created into the array: \n\n const newOperation = {\n [OPERATION_TYPE_VARIES]: {\n create: {\n resourceName: `customers/${customerId}/[EXACT_PATH_VARIES]/${getNextTempId()}`\n // Other fields, relevant to the resource being created.\n }\n }\n }\n operations.push(newOperation);\n\nYou can read more and see an example operation on the\n[Google Ads API REST mutate documentation](/google-ads/api/rest/common/mutate).\n\nOnce you have constructed all of our operations, execute them in a single\nbatch: \n\n AdsApp.mutateAll(operations);"]]