Hello again, GoogleAds Team!
According to second problem, the most close service seems
CampaignConversionGoalService and closest way to solve it -- update
existing ConversionGoals to achieve Website Traffic marketing objective.
But it raises INCONSISTENT_FIELD_VALUES error for every resource_name.
Thanks in advance!
пятница, 1 апреля 2022 г. в 17:38:46 UTC+3, Andrew Hrimov:
> Hello, I'm developing platform that allows to create-update-delete
> campaigns on GoogleAds (v10) using Python. At now, I do CUD operations for
> Smart Display Ad, and I have 2 misunderstandings about API. I have found
> how to manage almost all options exclude these ones:
> [image: campaign-problems.png]
> So, my questions are:
> 1. I've found how to set GeoTargets (create & update). But how can I set
> Target option to "Presence" via API? Which method to use (service,
> operation)?
> [image: location.png]
>
> 2. How can I set Marketing objective to "Website traffic"? Which method
> to use (service, operation)?
>
> [image: objective.png]
>
> Thanks in advance!
>
>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/267b641c-e4dd-4a96-9c73-ee3bb683acb1n%40googlegroups.com.
def create_marketing_objective(client, customer_id: str, campaign_resource: str):
query = 'SELECT campaign_conversion_goal.resource_name, ' \
'campaign_conversion_goal.origin, campaign_conversion_goal.category, ' \
'campaign_conversion_goal.biddable ' \
'FROM campaign_conversion_goal ' \
f"WHERE campaign.resource_name = '{campaign_resource}'"
ga_service = client.get_service("GoogleAdsService")
search_request = client.get_type("SearchGoogleAdsRequest")
search_request.customer_id = customer_id
search_request.query = query
search_request.page_size = 1_000
results = ga_service.search(request=search_request)
conversion_goal_service = client.get_service("CampaignConversionGoalService")
ops = list()
for row in results:
resource = row.campaign_conversion_goal.resource_name
conversion_goal_operation = client.get_type("CampaignConversionGoalOperation")
goal = conversion_goal_operation.update
goal.category = client.enums.ConversionActionCategoryEnum.DEFAULT
goal.origin = client.enums.ConversionOriginEnum.WEBSITE
goal.resource_name = resource
client.copy_from(
conversion_goal_operation.update_mask,
protobuf_helpers.field_mask(None, goal._pb), # noqa
)
ops.append(conversion_goal_operation)
conversion_goal_service.mutate_campaign_conversion_goals(
customer_id=customer_id, operations=ops
)