I'm trying to create a campaign that must target mobile devices only, using the google ads API client library in python. The documentation says that I have to modify the DeviceInfo criteria, but that attribute is immutable. This is my code rn:

campaign_service = client.get_service("CampaignService")     campaign_criterion_service = client.get_service("CampaignCriterionService")     # Create the campaign criterion.     campaign_criterion_operation = client.get_type("CampaignCriterionOperation")     campaign_criterion = campaign_criterion_operation.create     campaign_criterion.campaign = campaign_service.campaign_path(         customer_id, campaign_id     )          campaign_criterion.device = client.enums.DeviceEnum.MOBILE 

What am I missing?

Tag:google-ads-api

Only one comment.

  1. Gabriel Viviani

    For most of Enums you have to use the .type_ after the value you wanna set. So you should use:

    campaign_criterion.device.type_ = client.enums.DeviceEnum.MOBILE

    A nice advice is to download library code and goes into reading that.

Add a new comment.