Skip to content

Commit

Permalink
Demonstrate passing consent in offline conversion upload
Browse files Browse the repository at this point in the history
Change-Id: Ide8079c878fb3f5a5d5d7220e0e00a35d987d4f3
  • Loading branch information
jradcliff committed Jan 11, 2024
1 parent 499ad2f commit 7a78308
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/remarketing/upload_offline_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def main(
gbraid,
wbraid,
order_id,
ad_user_data_consent,
):
"""Creates a click conversion with a default currency of USD.
Expand All @@ -62,6 +63,7 @@ def main(
wbraid: The WBRAID for the iOS app conversion. If set, the gclid and
gbraid parameters must be None.
order_id: The order ID for the click conversion.
ad_user_data_consent: The ad user data consent for the click.
"""
click_conversion = client.get_type("ClickConversion")
conversion_upload_service = client.get_service("ConversionUploadService")
Expand Down Expand Up @@ -97,6 +99,15 @@ def main(
if order_id:
click_conversion.order_id = order_id

# Sets the consent information, if provided.
if ad_user_data_consent:
# Specifies whether user consent was obtained for the data you are
# uploading. For more details, see:
# https://www.google.com/about/company/user-consent-policy
click_conversion.consent.ad_user_data = client.enums.ConsentStatusEnum[
ad_user_data_consent
]

# Uploads the click conversion. Partial failure must be set to True here.
#
# NOTE: This request only uploads a single conversion, but if you have
Expand Down Expand Up @@ -209,6 +220,15 @@ def main(
type=str,
help="The order ID for the click conversion.",
)
parser.add_argument(
"-d",
"--ad_user_data_consent",
type=str,
choices=[e.name for e in googleads_client.enums.ConsentStatusEnum],
help=(
"The ad user data consent for the click."
),
)
args = parser.parse_args()

try:
Expand All @@ -224,6 +244,7 @@ def main(
args.gbraid,
args.wbraid,
args.order_id,
args.ad_user_data_consent,
)
except GoogleAdsException as ex:
print(
Expand Down

0 comments on commit 7a78308

Please sign in to comment.