Also, whats the best practice here:
# Create campaign operation.
campaign_operation = client.get_type("CampaignOperation")
campaign = campaign_operation.update
campaign.resource_name = resource_name
If I iterate through a list of campaigns that need to be updated, should I
recreate the campaign object every time? By calling
campaign_operation.update ?
Or can I just clear out the current object? Or perhaps reassign the
resource name on it?
On Wednesday, February 1, 2023 at 11:20:01 AM UTC-8 Chad Wood wrote:
> Is it possible to retrieve url_custom_parameters field via the
> CampaignServiceClient object?
> I see it can retrieve the resource name.
>
> campaign_service.url_custom_parameters()
> >>> AttributeError: 'CampaignServiceClient' object has no attribute
> 'url_custom_parameters'
>
> On Wednesday, February 1, 2023 at 9:02:03 AM UTC-8 Chad Wood wrote:
>
>> I think I found my answer. Sorry, seems jumping into the docs at 'update
>> campaign' left me unaware of some important concepts.
>> You pre-specify what fields you intend to change, and any attempted
>> changes to a campaign field NOT specified in the field mask is ignored.
>> To me, this sounds like the concept of scopes, but applied to campaign
>> fields instead of API endpoints, and it just doesn't raise error if
>> breached.
>>
>> Is this understanding correct?
>>
>> On Wednesday, February 1, 2023 at 8:55:50 AM UTC-8 Chad Wood wrote:
>>
>>> Hello,
>>>
>>> Any chance you can help me understand whats going on in the example code
>>> from that link? (Its slightly rewritten here)
>>>
>>> ```
>>> def main(client, customer_id, campaign_id):
>>> # For creating the campaign object
>>> campaign_service = client.get_service("CampaignService")
>>> resource_name = campaign_service.campaign_path(
>>> customer_id, campaign_id
>>> )
>>>
>>> # Create campaign operation.
>>> campaign_operation = client.get_type("CampaignOperation")
>>> campaign = campaign_operation.update
>>>
>>> # Updates campaign object with resource ID
>>> campaign.resource_name = resource_name
>>>
>>> #campaign.status = client.enums.CampaignStatusEnum.PAUSED
>>> #campaign.network_settings.target_search_network = False
>>>
>>> # Retrieve a FieldMask for the fields configured in the campaign.
>>> client.copy_from(
>>> campaign_operation.update_mask,
>>> protobuf_helpers.field_mask(None, campaign._pb),
>>> )
>>>
>>> campaign_response = campaign_service.mutate_campaigns(
>>> customer_id=customer_id, operations=[campaign_operation]
>>> )
>>>
>>> print(f"Updated campaign
>>> {campaign_response.results[0].resource_name}.")
>>> ```
>>>
>>> Specifically, what is client.copy_from doing? What is a "FieldMask", and
>>> do I need to reproduce this for what I am trying to achieve?
>>>
>>> Thanks,
>>> Chad
>>>
>>> On Thursday, January 26, 2023 at 8:17:57 AM UTC-8 Chad Wood wrote:
>>>
>>>> Hey Abigail,
>>>>
>>>> Thanks a lot! This is going to be a huge help for tracking.
>>>>
>>>>
>>>> On Wednesday, January 25, 2023 at 10:04:20 PM UTC-8 adsapi wrote:
>>>>
>>>>> Hi Chad,
>>>>>
>>>>> Thank you for reaching out to Google Ads API Support.
>>>>>
>>>>>
>>>>> *>> Is it possible to add, remove, and change custom ValueTrack
>>>>> parameters at the campaign level via API? *
>>>>> To answer your question, yes, it is possible. As per our documentation
>>>>> about Custom Parameters
>>>>> <https://developers.google.com/google-ads/api/docs/ads/upgraded-urls/fields#custom_parameters>,
>>>>>
>>>>> the Campaign
>>>>> <https://developers.google.com/google-ads/api/docs/ads/upgraded-urls/supported-entities>
>>>>>
>>>>> is a supported entity for Custom Parameters, and this is defined by the
>>>>> url_custom_parameters
>>>>> <https://developers.google.com/google-ads/api/reference/rpc/v12/Campaign#url_custom_parameters[]>
>>>>>
>>>>> attribute.
>>>>>
>>>>> Although there is no code example from the documentation about adding
>>>>> / updating / removing Custom Parameters, you may refer to this update
>>>>> campaign example
>>>>> <https://developers.google.com/google-ads/api/samples/update-campaign#python>
>>>>>
>>>>> from the documentation. They are a little bit similar, you just have to
>>>>> define your Campaign object, and set the url_custom_parameters
>>>>> <https://developers.google.com/google-ads/api/reference/rpc/v12/Campaign#url_custom_parameters[]>
>>>>> .
>>>>>
>>>>> Also, you may see the following links for additional references.
>>>>>
>>>>> - ValueTrack Parameters for Upgraded URLs
>>>>>
>>>>> <https://developers.google.com/google-ads/api/docs/ads/upgraded-urls/value-track>
>>>>>
>>>>> - Mapping ValueTrack Parameters with Report Fields
>>>>>
>>>>> <https://developers.google.com/google-ads/api/docs/reporting/valuetrack-mapping>
>>>>>
>>>>>
>>>>> Let me know if you have any other questions related to the Google Ads
>>>>> API.
>>>>>
>>>>> Regards,
>>>>> [image: Google Logo]
>>>>> Abigail
>>>>> Google Ads API Team
>>>>>
>>>>>
>>>>> ref:_00D1U1174p._5004Q2iNsig:ref
>>>>>
>>>>
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/82b11071-63e0-4d15-a9e9-01303bf7cfden%40googlegroups.com.