변형 전략
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 가이드는 별도의 요청에서 각 항목을 한 번에 하나씩 만드는 대신 단일 원자 요청에서 전체 캠페인을 만든다고 가정하는 기존 실적 최대화 캠페인 가이드와 정확히 유사한 방식으로 구성됩니다. API 응답을 받을 때까지는 전체 리소스 이름을 알 수 없으므로 임시 ID를 사용하여 리소스를 서로 연결해야 합니다.
이렇게 하려면 중복된 임시 ID가 생성되지 않도록 코드를 작성해야 합니다.
let nextId = -1;
function getNextTempId() {
const ret = nextId;
nextId -= 1;
return ret;
}
getNextTempId
에 대한 각 연속 호출은 이전 호출보다 1이 작은 숫자를 반환합니다. 모든 임시 ID는 음수여야 하므로 -1부터 시작합니다.
이제 모든 작업을 저장할 배열을 만들 수 있습니다.
const operations = [];
모든 리소스 이름에 필요하므로 캠페인을 만들려는 고객의 고객 ID가 자주 필요합니다.
const customerId = AdsApp.currentAccount().getCustomerId();
새 작업을 만들 때마다 리소스 이름에서 다음 임시 ID를 사용하여 나중에 이 객체를 참조하고 생성된 객체를 배열에 삽입할 수 있습니다.
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 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-27(UTC)
[null,null,["최종 업데이트: 2025-08-27(UTC)"],[[["\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);"]]