Closed ezStahl closed 7 months ago
You do this when you set up adwords client
adwords_client = adwords.AdWordsClient.LoadFromStorage(auth_file)
adwords_client.partial_failure = True
Thanks @sakkammadam for your response.
I was in particular in search for the objects to refer to in the response since the documentation did not specify them, but eventually managed to come up with a solution with a colleague of mine. In case anyone is interested in returning the error message for offline conversion feed service here is our solution.
The objects I was looking for are: offline_conversion_response['partialFailureErrors'] and within that ['reason']
def upload_offline_conversion(client, conversion_name, click_id, conversion_time, conversion_value):
print('Uploading %s' % click_id)
# Initialize appropriate services.
offline_conversion_feed_service = client.GetService('OfflineConversionFeedService') # , version='v201809' # VERSION REMOVED FOR COMPATIBILITY
# Associate offline conversions with the existing named conversion tracker. If
# this tracker was newly created, it may be a few hours before it can accept
# conversions.
feed = {
'conversionName': conversion_name,
'conversionTime': conversion_time,
'conversionValue': conversion_value,
'googleClickId': click_id,
# Optional: To upload fractional conversion credits, set the external
# attribution model and credit. To use this feature, your conversion
# tracker should be marked as externally attributed. To learn more about
# importing externally attributed conversins, see:
# https://developers.google.com/adwords/api/docs/guides/conversion-tracking#importing_externally_attributed_conversions
#'externalAttributionCredit': 0.3,
#'externalAttributionModel': 'Linear'
}
# Note: OfflineConversionFeedOperation supports only the ADD operator, SET and REMOVE are not supported.
offline_conversion_operation = {
'operator': 'ADD',
'operand': feed
}
# Reports an offline conversion for each entry in offline_conversion_operation.
offline_conversion_response = offline_conversion_feed_service.mutate([offline_conversion_operation])
new_feed = offline_conversion_response['value']
error_feed = offline_conversion_response['partialFailureErrors']
if new_feed == [None]:
for f in error_feed:
print('Error in upload: %s' % f['reason'])
else:
for f in new_feed:
print('Uploaded offline conversion value of %s for Google Click ID '
'%s to %s.' % (f['conversionValue'],
f['googleClickId'],
f['conversionName']))
The AdWords API has been turned down and replaced by the Google Ads API: https://github.com/googleads/google-ads-python
Hello there,
I am trying to implement partial failure handling for the OfflineConversionFeedService, but unfortunately I only came across a guideance for partial failure that uses ad_group_criterion_service.
Would you be so kind to let me know how to implement this for offline conversions?
Thanks a lot in advance! Adam