The mutate strategy refers to using AdsApp.mutate to make API calls directly, rather than relying on Google Ads scripts specific objects. This has the benefit of letting you access all features of the API more quickly, and has a lower barrier to entry if you're already familiar with the API syntax.
Создайте кампанию Performance Max с помощью mutate.
This guide assumes that you create the entire campaign in a single atomic request, rather than creating each individual entity in separate requests. This means that you'll need to set up and use temporary IDs to link resources to each other.
После этого создайте массив для хранения всех операций:
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);
You can read more and see an example operation on the Google Ads API REST mutate documentation . Learn about the required and optional components of a Performance Max campaign, and create operations for your needs.
После того как вы сформируете все необходимые операции, выполните их одним пакетом:
AdsApp.mutateAll(operations);