@pipedream/google_ads 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/add-contact-to-list-by-email/add-contact-to-list-by-email.mjs +1 -1
- package/actions/create-ad-group-report/create-ad-group-report.mjs +1 -1
- package/actions/create-ad-report/create-ad-report.mjs +1 -1
- package/actions/create-campaign-report/create-campaign-report.mjs +1 -1
- package/actions/create-customer-list/create-customer-list.mjs +1 -1
- package/actions/create-customer-report/create-customer-report.mjs +1 -1
- package/actions/create-or-remove-campaign-criteria/create-or-remove-campaign-criteria.mjs +214 -0
- package/actions/create-or-remove-campaign-shared-set/create-or-remove-campaign-shared-set.mjs +155 -0
- package/actions/create-or-remove-shared-criteria/create-or-remove-shared-criteria.mjs +180 -0
- package/actions/create-or-update-ad-group/create-or-update-ad-group.mjs +315 -0
- package/actions/create-or-update-ad-group-ad/create-or-update-ad-group-ad.mjs +203 -0
- package/actions/create-or-update-bidding-strategy/create-or-update-bidding-strategy.mjs +180 -0
- package/actions/create-or-update-campaign/create-or-update-campaign.mjs +243 -0
- package/actions/create-or-update-campaign-budget/create-or-update-campaign-budget.mjs +212 -0
- package/actions/create-or-update-keywords/create-or-update-keywords.mjs +275 -0
- package/actions/create-or-update-shared-sets/create-or-update-shared-sets.mjs +180 -0
- package/actions/create-report/create-report.mjs +123 -121
- package/actions/create-responsive-search-ad/create-responsive-search-ad.mjs +202 -0
- package/actions/generate-keyword-ideas/generate-keyword-ideas.mjs +1 -1
- package/actions/get-keyword-quality-scores/get-keyword-quality-scores.mjs +107 -0
- package/actions/list-account-id-options/list-account-id-options.mjs +1 -1
- package/actions/list-ad-group-ads/list-ad-group-ads.mjs +55 -0
- package/actions/list-ad-group-criteria/list-ad-group-criteria.mjs +55 -0
- package/actions/list-ad-groups/list-ad-groups.mjs +55 -0
- package/actions/list-bidding-strategies/list-bidding-strategies.mjs +55 -0
- package/actions/list-campaign-budgets/list-campaign-budgets.mjs +55 -0
- package/actions/list-campaign-criteria/list-campaign-criteria.mjs +55 -0
- package/actions/list-campaign-shared-sets/list-campaign-shared-sets.mjs +55 -0
- package/actions/list-campaigns/list-campaigns.mjs +55 -0
- package/actions/list-customer-clients/list-customer-clients.mjs +43 -0
- package/actions/list-keywords/list-keywords.mjs +55 -0
- package/actions/list-shared-criteria/list-shared-criteria.mjs +55 -0
- package/actions/list-shared-sets/list-shared-sets.mjs +55 -0
- package/actions/send-offline-conversion/send-offline-conversion.mjs +1 -1
- package/actions/update-campaign-ai-max-settings/update-campaign-ai-max-settings.mjs +167 -0
- package/common/constants.mjs +269 -0
- package/common/queries.mjs +4 -2
- package/common/utils.mjs +4 -0
- package/google_ads.app.mjs +591 -3
- package/package.json +1 -1
- package/sources/new-campaign-created/new-campaign-created.mjs +1 -1
- package/sources/new-lead-form-entry/new-lead-form-entry.mjs +1 -1
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import googleAds from "../../google_ads.app.mjs";
|
|
3
|
+
import {
|
|
4
|
+
ADVERTISING_CHANNEL_TYPES,
|
|
5
|
+
CAMPAIGN_OPERATION_TYPES,
|
|
6
|
+
CAMPAIGN_STATUSES,
|
|
7
|
+
} from "../../common/constants.mjs";
|
|
8
|
+
import { parseObject } from "../../common/utils.mjs";
|
|
9
|
+
import { getAdditionalFields } from "../common/props.mjs";
|
|
10
|
+
|
|
11
|
+
const docLink =
|
|
12
|
+
"https://developers.google.com/google-ads/api/reference/rpc/v21/CampaignService/MutateCampaigns?transport=rest";
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
key: "google_ads-create-or-update-campaign",
|
|
16
|
+
name: "Create or Update Campaign",
|
|
17
|
+
description: `Creates or updates a campaign. [See the documentation](${docLink})`,
|
|
18
|
+
version: "0.0.1",
|
|
19
|
+
type: "action",
|
|
20
|
+
annotations: {
|
|
21
|
+
destructiveHint: true,
|
|
22
|
+
openWorldHint: true,
|
|
23
|
+
readOnlyHint: false,
|
|
24
|
+
},
|
|
25
|
+
props: {
|
|
26
|
+
googleAds,
|
|
27
|
+
accountId: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
googleAds,
|
|
30
|
+
"accountId",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
customerClientId: {
|
|
34
|
+
propDefinition: [
|
|
35
|
+
googleAds,
|
|
36
|
+
"customerClientId",
|
|
37
|
+
({ accountId }) => ({
|
|
38
|
+
accountId,
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
optional: true,
|
|
42
|
+
},
|
|
43
|
+
operationType: {
|
|
44
|
+
type: "string",
|
|
45
|
+
label: "Operation Type",
|
|
46
|
+
description: "Whether to create, update, or remove a campaign.",
|
|
47
|
+
options: CAMPAIGN_OPERATION_TYPES,
|
|
48
|
+
},
|
|
49
|
+
campaignId: {
|
|
50
|
+
propDefinition: [
|
|
51
|
+
googleAds,
|
|
52
|
+
"campaignId",
|
|
53
|
+
({
|
|
54
|
+
accountId, customerClientId,
|
|
55
|
+
}) => ({
|
|
56
|
+
accountId,
|
|
57
|
+
customerClientId,
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
description: "The campaign to update or remove. Required for **Update** and **Remove** operations.",
|
|
61
|
+
optional: true,
|
|
62
|
+
},
|
|
63
|
+
updateMask: {
|
|
64
|
+
type: "string",
|
|
65
|
+
label: "Update Mask",
|
|
66
|
+
description:
|
|
67
|
+
"Comma-separated list of fields to update (e.g., `name,status`). Only used for **update** operations.",
|
|
68
|
+
optional: true,
|
|
69
|
+
},
|
|
70
|
+
name: {
|
|
71
|
+
type: "string",
|
|
72
|
+
label: "Name",
|
|
73
|
+
description:
|
|
74
|
+
"The name of the campaign. Required for **create** operations.",
|
|
75
|
+
optional: true,
|
|
76
|
+
},
|
|
77
|
+
advertisingChannelType: {
|
|
78
|
+
type: "string",
|
|
79
|
+
label: "Advertising Channel Type",
|
|
80
|
+
description:
|
|
81
|
+
"The primary serving target for ads within the campaign. Required for **create** operations.",
|
|
82
|
+
options: ADVERTISING_CHANNEL_TYPES,
|
|
83
|
+
optional: true,
|
|
84
|
+
},
|
|
85
|
+
campaignBudget: {
|
|
86
|
+
type: "string",
|
|
87
|
+
label: "Campaign Budget",
|
|
88
|
+
description:
|
|
89
|
+
"The resource name of the campaign budget (e.g., `customers/{customer_id}/campaignBudgets/{budget_id}`). Required for **create** operations.",
|
|
90
|
+
optional: true,
|
|
91
|
+
},
|
|
92
|
+
status: {
|
|
93
|
+
type: "string",
|
|
94
|
+
label: "Status",
|
|
95
|
+
description: "The status of the campaign.",
|
|
96
|
+
options: CAMPAIGN_STATUSES,
|
|
97
|
+
optional: true,
|
|
98
|
+
},
|
|
99
|
+
startDate: {
|
|
100
|
+
type: "string",
|
|
101
|
+
label: "Start Date",
|
|
102
|
+
description:
|
|
103
|
+
"The date when the campaign starts serving ads, formatted as `YYYY-MM-DD`.",
|
|
104
|
+
optional: true,
|
|
105
|
+
},
|
|
106
|
+
endDate: {
|
|
107
|
+
type: "string",
|
|
108
|
+
label: "End Date",
|
|
109
|
+
description:
|
|
110
|
+
"The last day the campaign serves ads, formatted as `YYYY-MM-DD`. Leave blank for no end date.",
|
|
111
|
+
optional: true,
|
|
112
|
+
},
|
|
113
|
+
trackingUrlTemplate: {
|
|
114
|
+
type: "string",
|
|
115
|
+
label: "Tracking URL Template",
|
|
116
|
+
description: "The URL template for constructing a tracking URL.",
|
|
117
|
+
optional: true,
|
|
118
|
+
},
|
|
119
|
+
additionalFields: getAdditionalFields(docLink),
|
|
120
|
+
},
|
|
121
|
+
async run({ $ }) {
|
|
122
|
+
const {
|
|
123
|
+
googleAds,
|
|
124
|
+
accountId,
|
|
125
|
+
customerClientId,
|
|
126
|
+
operationType,
|
|
127
|
+
campaignId,
|
|
128
|
+
updateMask,
|
|
129
|
+
name,
|
|
130
|
+
advertisingChannelType,
|
|
131
|
+
campaignBudget,
|
|
132
|
+
status,
|
|
133
|
+
startDate,
|
|
134
|
+
endDate,
|
|
135
|
+
trackingUrlTemplate,
|
|
136
|
+
additionalFields,
|
|
137
|
+
} = this;
|
|
138
|
+
|
|
139
|
+
if ((operationType === "update" || operationType === "remove") && !campaignId) {
|
|
140
|
+
throw new ConfigurationError(
|
|
141
|
+
"**Campaign** is required for Update and Remove operations.",
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (operationType === "update" && !updateMask) {
|
|
146
|
+
throw new ConfigurationError(
|
|
147
|
+
"**Update Mask** is required for Update operations.",
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (operationType === "create") {
|
|
152
|
+
if (!name) {
|
|
153
|
+
throw new ConfigurationError(
|
|
154
|
+
"**Name** is required for Create operations.",
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
if (!advertisingChannelType) {
|
|
158
|
+
throw new ConfigurationError(
|
|
159
|
+
"**Advertising Channel Type** is required for Create operations.",
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (!campaignBudget) {
|
|
163
|
+
throw new ConfigurationError(
|
|
164
|
+
"**Campaign Budget** is required for Create operations.",
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const customerId = customerClientId ?? accountId;
|
|
170
|
+
const resourceName = campaignId
|
|
171
|
+
? `customers/${customerId}/campaigns/${campaignId}`
|
|
172
|
+
: undefined;
|
|
173
|
+
|
|
174
|
+
let operation;
|
|
175
|
+
|
|
176
|
+
if (operationType === "remove") {
|
|
177
|
+
operation = {
|
|
178
|
+
remove: resourceName,
|
|
179
|
+
};
|
|
180
|
+
} else {
|
|
181
|
+
const campaignData = {
|
|
182
|
+
...(resourceName && {
|
|
183
|
+
resourceName,
|
|
184
|
+
}),
|
|
185
|
+
...(name && {
|
|
186
|
+
name,
|
|
187
|
+
}),
|
|
188
|
+
...(advertisingChannelType && {
|
|
189
|
+
advertisingChannelType,
|
|
190
|
+
}),
|
|
191
|
+
...(campaignBudget && {
|
|
192
|
+
campaignBudget,
|
|
193
|
+
}),
|
|
194
|
+
...(status && {
|
|
195
|
+
status,
|
|
196
|
+
}),
|
|
197
|
+
...(startDate && {
|
|
198
|
+
startDate,
|
|
199
|
+
}),
|
|
200
|
+
...(endDate && {
|
|
201
|
+
endDate,
|
|
202
|
+
}),
|
|
203
|
+
...(trackingUrlTemplate && {
|
|
204
|
+
trackingUrlTemplate,
|
|
205
|
+
}),
|
|
206
|
+
...parseObject(additionalFields),
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
if (operationType === "update") {
|
|
210
|
+
operation = {
|
|
211
|
+
update: campaignData,
|
|
212
|
+
updateMask,
|
|
213
|
+
};
|
|
214
|
+
} else {
|
|
215
|
+
operation = {
|
|
216
|
+
create: campaignData,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const response = await googleAds.mutateCampaign({
|
|
222
|
+
$,
|
|
223
|
+
accountId,
|
|
224
|
+
customerClientId,
|
|
225
|
+
data: {
|
|
226
|
+
operations: [
|
|
227
|
+
operation,
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const result = response?.results?.[0];
|
|
233
|
+
const id = result?.resourceName?.split("/").pop();
|
|
234
|
+
|
|
235
|
+
$.export(
|
|
236
|
+
"$summary",
|
|
237
|
+
`Successfully ${operationType}d campaign${id
|
|
238
|
+
? ` with ID \`${id}\``
|
|
239
|
+
: ""}.`,
|
|
240
|
+
);
|
|
241
|
+
return response;
|
|
242
|
+
},
|
|
243
|
+
};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import googleAds from "../../google_ads.app.mjs";
|
|
3
|
+
import {
|
|
4
|
+
BUDGET_DELIVERY_METHODS,
|
|
5
|
+
BUDGET_PERIODS,
|
|
6
|
+
CAMPAIGN_OPERATION_TYPES,
|
|
7
|
+
} from "../../common/constants.mjs";
|
|
8
|
+
import { parseObject } from "../../common/utils.mjs";
|
|
9
|
+
import { getAdditionalFields } from "../common/props.mjs";
|
|
10
|
+
|
|
11
|
+
const docLink =
|
|
12
|
+
"https://developers.google.com/google-ads/api/reference/rpc/v21/CampaignBudgetService/MutateCampaignBudgets?transport=rest";
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
key: "google_ads-create-or-update-campaign-budget",
|
|
16
|
+
name: "Create or Update Campaign Budget",
|
|
17
|
+
description: `Creates, updates, or removes a campaign budget. [See the documentation](${docLink})`,
|
|
18
|
+
version: "0.0.1",
|
|
19
|
+
type: "action",
|
|
20
|
+
annotations: {
|
|
21
|
+
destructiveHint: true,
|
|
22
|
+
openWorldHint: true,
|
|
23
|
+
readOnlyHint: false,
|
|
24
|
+
},
|
|
25
|
+
props: {
|
|
26
|
+
googleAds,
|
|
27
|
+
accountId: {
|
|
28
|
+
propDefinition: [
|
|
29
|
+
googleAds,
|
|
30
|
+
"accountId",
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
customerClientId: {
|
|
34
|
+
propDefinition: [
|
|
35
|
+
googleAds,
|
|
36
|
+
"customerClientId",
|
|
37
|
+
({ accountId }) => ({
|
|
38
|
+
accountId,
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
optional: true,
|
|
42
|
+
},
|
|
43
|
+
operationType: {
|
|
44
|
+
type: "string",
|
|
45
|
+
label: "Operation Type",
|
|
46
|
+
description: "Whether to create, update, or remove a campaign budget.",
|
|
47
|
+
options: CAMPAIGN_OPERATION_TYPES,
|
|
48
|
+
},
|
|
49
|
+
campaignBudgetId: {
|
|
50
|
+
propDefinition: [
|
|
51
|
+
googleAds,
|
|
52
|
+
"campaignBudgetId",
|
|
53
|
+
({
|
|
54
|
+
accountId, customerClientId,
|
|
55
|
+
}) => ({
|
|
56
|
+
accountId,
|
|
57
|
+
customerClientId,
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
description: "The budget to update or remove. Required for **Update** and **Remove** operations.",
|
|
61
|
+
optional: true,
|
|
62
|
+
},
|
|
63
|
+
updateMask: {
|
|
64
|
+
type: "string",
|
|
65
|
+
label: "Update Mask",
|
|
66
|
+
description: "Comma-separated list of fields to update (e.g., `name,amountMicros`). Required for **Update** operations.",
|
|
67
|
+
optional: true,
|
|
68
|
+
},
|
|
69
|
+
name: {
|
|
70
|
+
type: "string",
|
|
71
|
+
label: "Name",
|
|
72
|
+
description: "The name of the budget. Required for **Create** operations.",
|
|
73
|
+
optional: true,
|
|
74
|
+
},
|
|
75
|
+
amountMicros: {
|
|
76
|
+
type: "string",
|
|
77
|
+
label: "Amount (Micros)",
|
|
78
|
+
description: "The amount of the budget in micros (e.g., `1000000` = $1.00). Required for **Create** operations.",
|
|
79
|
+
optional: true,
|
|
80
|
+
},
|
|
81
|
+
deliveryMethod: {
|
|
82
|
+
type: "string",
|
|
83
|
+
label: "Delivery Method",
|
|
84
|
+
description: "How quickly the budget is spent throughout the day.",
|
|
85
|
+
options: BUDGET_DELIVERY_METHODS,
|
|
86
|
+
optional: true,
|
|
87
|
+
},
|
|
88
|
+
explicitlyShared: {
|
|
89
|
+
type: "boolean",
|
|
90
|
+
label: "Explicitly Shared",
|
|
91
|
+
description: "Whether this budget is explicitly shared across multiple campaigns. Immutable after creation.",
|
|
92
|
+
optional: true,
|
|
93
|
+
},
|
|
94
|
+
period: {
|
|
95
|
+
type: "string",
|
|
96
|
+
label: "Period",
|
|
97
|
+
description: "The period over which to spend the budget. Immutable after creation.",
|
|
98
|
+
options: BUDGET_PERIODS,
|
|
99
|
+
optional: true,
|
|
100
|
+
},
|
|
101
|
+
additionalFields: getAdditionalFields(docLink),
|
|
102
|
+
},
|
|
103
|
+
async run({ $ }) {
|
|
104
|
+
const {
|
|
105
|
+
googleAds,
|
|
106
|
+
accountId,
|
|
107
|
+
customerClientId,
|
|
108
|
+
operationType,
|
|
109
|
+
campaignBudgetId,
|
|
110
|
+
updateMask,
|
|
111
|
+
name,
|
|
112
|
+
amountMicros,
|
|
113
|
+
deliveryMethod,
|
|
114
|
+
explicitlyShared,
|
|
115
|
+
period,
|
|
116
|
+
additionalFields,
|
|
117
|
+
} = this;
|
|
118
|
+
|
|
119
|
+
if ((operationType === "update" || operationType === "remove") && !campaignBudgetId) {
|
|
120
|
+
throw new ConfigurationError(
|
|
121
|
+
"**Campaign Budget** is required for Update and Remove operations.",
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (operationType === "update" && !updateMask) {
|
|
126
|
+
throw new ConfigurationError(
|
|
127
|
+
"**Update Mask** is required for Update operations.",
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (operationType === "create") {
|
|
132
|
+
if (!name) {
|
|
133
|
+
throw new ConfigurationError(
|
|
134
|
+
"**Name** is required for Create operations.",
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
if (!amountMicros) {
|
|
138
|
+
throw new ConfigurationError(
|
|
139
|
+
"**Amount (Micros)** is required for Create operations.",
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const customerId = customerClientId ?? accountId;
|
|
145
|
+
const resourceName = campaignBudgetId
|
|
146
|
+
? `customers/${customerId}/campaignBudgets/${campaignBudgetId}`
|
|
147
|
+
: undefined;
|
|
148
|
+
|
|
149
|
+
let operation;
|
|
150
|
+
|
|
151
|
+
if (operationType === "remove") {
|
|
152
|
+
operation = {
|
|
153
|
+
remove: resourceName,
|
|
154
|
+
};
|
|
155
|
+
} else {
|
|
156
|
+
const budgetData = {
|
|
157
|
+
...(resourceName && {
|
|
158
|
+
resourceName,
|
|
159
|
+
}),
|
|
160
|
+
...(name && {
|
|
161
|
+
name,
|
|
162
|
+
}),
|
|
163
|
+
...(amountMicros && {
|
|
164
|
+
amountMicros,
|
|
165
|
+
}),
|
|
166
|
+
...(deliveryMethod && {
|
|
167
|
+
deliveryMethod,
|
|
168
|
+
}),
|
|
169
|
+
...(explicitlyShared !== undefined && {
|
|
170
|
+
explicitlyShared,
|
|
171
|
+
}),
|
|
172
|
+
...(period && {
|
|
173
|
+
period,
|
|
174
|
+
}),
|
|
175
|
+
...parseObject(additionalFields),
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
if (operationType === "update") {
|
|
179
|
+
operation = {
|
|
180
|
+
update: budgetData,
|
|
181
|
+
updateMask,
|
|
182
|
+
};
|
|
183
|
+
} else {
|
|
184
|
+
operation = {
|
|
185
|
+
create: budgetData,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const response = await googleAds.mutateCampaignBudgets({
|
|
191
|
+
$,
|
|
192
|
+
accountId,
|
|
193
|
+
customerClientId,
|
|
194
|
+
data: {
|
|
195
|
+
operations: [
|
|
196
|
+
operation,
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const result = response?.results?.[0];
|
|
202
|
+
const id = result?.resourceName?.split("/").pop();
|
|
203
|
+
|
|
204
|
+
$.export(
|
|
205
|
+
"$summary",
|
|
206
|
+
`Successfully ${operationType}d campaign budget${id
|
|
207
|
+
? ` with ID \`${id}\``
|
|
208
|
+
: ""}.`,
|
|
209
|
+
);
|
|
210
|
+
return response;
|
|
211
|
+
},
|
|
212
|
+
};
|