Skip to content

Commit 3000f18

Browse files
jradcliffBenRKarl
authored andcommitted
Demonstrate passing consent in offline conversion upload
Change-Id: Ide8079c878fb3f5a5d5d7220e0e00a35d987d4f3
1 parent 499ad2f commit 3000f18

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

examples/remarketing/upload_offline_conversion.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def main(
4040
gbraid,
4141
wbraid,
4242
order_id,
43+
ad_user_data_consent,
4344
):
4445
"""Creates a click conversion with a default currency of USD.
4546
@@ -62,6 +63,7 @@ def main(
6263
wbraid: The WBRAID for the iOS app conversion. If set, the gclid and
6364
gbraid parameters must be None.
6465
order_id: The order ID for the click conversion.
66+
ad_user_data_consent: The ad user data consent for the click.
6567
"""
6668
click_conversion = client.get_type("ClickConversion")
6769
conversion_upload_service = client.get_service("ConversionUploadService")
@@ -97,6 +99,15 @@ def main(
9799
if order_id:
98100
click_conversion.order_id = order_id
99101

102+
# Sets the consent information, if provided.
103+
if ad_user_data_consent:
104+
# Specifies whether user consent was obtained for the data you are
105+
# uploading. For more details, see:
106+
# https://www.google.com/about/company/user-consent-policy
107+
click_conversion.consent.ad_user_data = client.enums.ConsentStatusEnum[
108+
ad_user_data_consent
109+
]
110+
100111
# Uploads the click conversion. Partial failure must be set to True here.
101112
#
102113
# NOTE: This request only uploads a single conversion, but if you have
@@ -209,6 +220,15 @@ def main(
209220
type=str,
210221
help="The order ID for the click conversion.",
211222
)
223+
parser.add_argument(
224+
"-d",
225+
"--ad_user_data_consent",
226+
type=str,
227+
choices=[e.name for e in googleads_client.enums.ConsentStatusEnum],
228+
help=(
229+
"The ad user data consent for the click."
230+
),
231+
)
212232
args = parser.parse_args()
213233

214234
try:
@@ -224,6 +244,7 @@ def main(
224244
args.gbraid,
225245
args.wbraid,
226246
args.order_id,
247+
args.ad_user_data_consent,
227248
)
228249
except GoogleAdsException as ex:
229250
print(

0 commit comments

Comments
 (0)