google-ads-python icon indicating copy to clipboard operation
google-ads-python copied to clipboard

Adding Consent Field To OfflineUserDataJobOperation Job

Open masabni opened this issue 1 year ago • 3 comments

Whenever I try to add the consent field to the user data operation I get this error [ERROR] AttributeError: consent this is how I'm doing it in the code

    user_data_operation = client.get_type('OfflineUserDataJobOperation')

    user_data = user_data_operation.create

    user_identifier = client.get_type('UserIdentifier')

    user_identifier.hashed_email = normalize_and_hash(email)

    # add GRANTED consent for the user (2 is the enum value for GRANTED)
    user_data.consent.ad_user_data = 2
    user_data.consent.ad_personalization = 2

it looks like that doing it like user_data.consent.ad_user_data = 2 is not the correct way, I didn't find much documentation about this anywhere except for the examples and even there it's similar to my code. Can you please tell me what I'm doing wrong here, thanks in advance

masabni avatar Mar 04 '24 11:03 masabni

@masabni is this for a customer match user list? If so, then I suggest reading the documentation here.

BenRKarl avatar Mar 06 '24 17:03 BenRKarl

@BenRKarl it looks like I have the latest version of the package but still it gives error when accessing the consent attribute from the metadata

offline_user_data_job = client.get_type("OfflineUserDataJob")
offline_user_data_job.customer_match_user_list_metadata.consent.ad_user_data = (
            client.enums.ConsentStatusEnum.GRANTED
        )

are you sure the latest version has this attribute? can you confirm the version i need to use for this package, currently I'm using google-ads google-api-python-client packages

masabni avatar Mar 07 '24 16:03 masabni

hello @BenRKarl, it would be really great if I can get a confirmation about the consent attribute. Let me know how can I help here

masabni avatar Mar 20 '24 18:03 masabni

@masabni one thing to double-check is that you're using v15 of the API or later. You can specific which API version to use when initializing a client, as is shown here.

BenRKarl avatar Apr 15 '24 14:04 BenRKarl