Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrate passing consent in offline conversion upload #829

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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