変更戦略
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
このガイドでは、既存の P-MAX ガイドと完全に同等のコードを作成する方法を説明します。このガイドでは、各エンティティを個別のリクエストで 1 つずつ作成するのではなく、1 つのアトミック リクエストでキャンペーン全体を作成することを前提としています。つまり、API レスポンスが返されるまで完全なリソース名がわからないため、一時 ID を使用してリソースを相互にリンクする必要があります。
そのためには、重複する一時 ID が作成されないようにコードを記述する必要があります。
let nextId = -1;
function getNextTempId() {
const ret = nextId;
nextId -= 1;
return ret;
}
getNextTempId
を連続して呼び出すと、前の値より 1 小さい値が返されます。すべての一時 ID は負の値である必要があるため、-1 から始めます。
これで、すべてのオペレーションを保持する配列を作成できます。
const operations = [];
リソース名にはすべてお客様 ID が必要であるため、キャンペーンを作成するお客様のお客様 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 の変更に関するドキュメントをご覧ください。
すべてのオペレーションを作成したら、1 つのバッチで実行します。
AdsApp.mutateAll(operations);
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許��されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-06-04 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"]],["最終更新日 2025-06-04 UTC。"],[[["This 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."],["To link resources within the single request, temporary IDs are utilized and assigned with a function ensuring unique negative values for each."],["The guide involves constructing an array of operations, where each operation represents the creation of a specific campaign component."],["After 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 `AdsApp.mutateAll(operations)`."]]],[]]