-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathupload_call_conversion.sh
More file actions
74 lines (69 loc) · 2.77 KB
/
upload_call_conversion.sh
File metadata and controls
74 lines (69 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Copyright 2025 Google LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# https://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# [START upload_call_conversion]
# This code example uploads a call conversion.
#
# Variables:
# API_VERSION,
# CUSTOMER_ID,
# DEVELOPER_TOKEN,
# MANAGER_CUSTOMER_ID,
# OAUTH2_ACCESS_TOKEN:
# See https://developers.google.com/google-ads/api/rest/auth#request_headers
# for details.
#
# CONVERSION_ACTION_RESOURCE_NAME: Resource name of the conversion action
# associated with this conversion.
# CALLER_ID: The caller id from which this call was placed. Caller id is
# expected to be in E.164 format with preceding '+' sign, for example,
# "+18005550100".
# CALL_START_DATE_TIME: The date time at which the call occurred. The format
# is "yyyy-mm-dd hh:mm:ss+|-hh:mm", for example,
# "2019-01-01 12:32:45-08:00".
# CONVERSION_DATE_TIME: The date time at which the conversion occurred. The
# format is "yyyy-mm-dd hh:mm:ss+|-hh:mm", for example,
# "2019-01-01 12:32:45-08:00".
# CONVERSION_VALUE: The value of the conversion for the advertiser.
# CURRENCY_CODE: The currency code of the conversion value. This is the
# ISO 4217 3-character currency code. For example: USD, EUR.
# CONVERSION_CUSTOM_VARIABLE: The name of the conversion custom variable.
# CONVERSION_CUSTOM_VARIABLE_VALUE: The value of the conversion custom
# variable.
curl -f --request POST \
"https://googleads.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}:uploadCallConversions" \
--header "Content-Type: application/json" \
--header "developer-token: ${DEVELOPER_TOKEN}" \
--header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \
--header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \
--data @- <<EOF
{
"conversions": [
{
"conversionAction": "${CONVERSION_ACTION_RESOURCE_NAME}",
"callerId": "${CALLER_ID}",
"callStartDateTime": "${CALL_START_DATE_TIME}",
"conversionDateTime": "${CONVERSION_DATE_TIME}",
"conversionValue": ${CONVERSION_VALUE},
"currencyCode": "${CURRENCY_CODE}",
"customVariables": [
{
"conversionCustomVariable": "${CONVERSION_CUSTOM_VARIABLE}",
"value": "${CONVERSION_CUSTOM_VARIABLE_VALUE}"
}
],
"consent": {
"adUserData": "GRANTED"
}
}
]
}
EOF
# [END upload_call_conversion]