Python response success or failure logging

31 views
Skip to first unread message

Richard Atkins

unread,
Jul 30, 2019, 6:26:44 PM7/30/19
to AdWords API and Google Ads API Forum
Hi, Sample code is below. I am trying to figure out how to tell if an offline conversion has been successful or failed when processed by the API. I have enabled logging, and can see the SOAP response but that does not indicate either. Many thanks in advance!


# ... conversion and click values assigned previously
feed = {
'conversionName': conversion_name,
'conversionTime': conversion_time,
'conversionValue': conversion_value,
'googleClickId': click_id,
}

offline_conversion_operation = {
'operator': 'ADD',
'operand': feed
}

offline_conversion_response = offline_conversion_feed_service.mutate(
[offline_conversion_operation])
new_feed = offline_conversion_response['value']


Logging;

Request made: Service: "OfflineConversionFeedService" Method: "mutate" URL: "https://adwords.google.com/api/adwords/cm/v201809/OfflineConversionFeedService"
Outgoing request: {'SOAPAction': '""', 'Content-Type': 'text/xml; charset=utf-8', 'authorization': 'REDACTED'}
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
  <soap-env:Header>
    <ns0:RequestHeader xmlns:ns0="https://adwords.google.com/api/adwords/cm/v201809">
      <ns0:developerToken>REDACTED</ns0:developerToken>
      <ns0:userAgent>unknown (AwApi-Python, googleads/20.0.0, Python/3.7.2, zeep)</ns0:userAgent>
      <ns0:validateOnly>false</ns0:validateOnly>
      <ns0:partialFailure>false</ns0:partialFailure>
    </ns0:RequestHeader>
  </soap-env:Header>
  <soap-env:Body>
      <ns0:operations>
        <ns0:operator>ADD</ns0:operator>
        <ns0:operand>
          <ns0:googleClickId><snip></ns0:googleClickId>
          <ns0:conversionName>something</ns0:conversionName>
          <ns0:conversionTime>20190725 000000 Etc/GMT</ns0:conversionTime>
          <ns0:conversionValue>100.0</ns0:conversionValue>
        </ns0:operand>
      </ns0:operations>
    </ns0:mutate>
  </soap-env:Body>
</soap-env:Envelope>

Incoming response: 
b'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">\n  <soap:Header>\n    <ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201809">\n      <requestId>0005<snip>269f2</requestId>\n      <serviceName>OfflineConversionFeedService</serviceName>\n      <methodName>mutate</methodName>\n      <operations>1</operations>\n      <responseTime>212</responseTime>\n    </ResponseHeader>\n  </soap:Header>\n  <soap:Body>\n    <mutateResponse xmlns="https://adwords.google.com/api/adwords/cm/v201809">\n      <rval>\n        <ListReturnValue.Type>OfflineConversionFeedReturnValue</ListReturnValue.Type>\n        <value>\n          <googleClickId><snip></googleClickId>\n          <conversionName>PLV</conversionName>\n          <conversionTime>2019mmdd 000000 Etc/GMT</conversionTime>\n          <conversionValue>100.0</conversionValue>\n        </value>\n      </rval>\n    </mutateResponse>\n  </soap:Body>\n</soap:Envelope>\n'
<class 'list'>
<class 'zeep.objects.OfflineConversionFeedReturnValue'>
<class 'list'>
[{
    'googleClickId': '<snip>',
    'conversionName': 'something',
    'conversionTime': '20190725 000000 Etc/GMT',
    'conversionValue': 100.0,
    'conversionCurrencyCode': None,
    'externalAttributionCredit': None,
    'externalAttributionModel': None
}]

Google Ads API Forum Advisor Prod

unread,
Jul 30, 2019, 10:28:16 PM7/30/19
to adwor...@googlegroups.com
Hi Richard,

Looking at the SOAP response, it appears that no <error> elements were returned. This should indicate that your conversion upload request has been successful. You can refer to this documentation to determine which possible errors would be returned when using the OfflineConversionFeedService.

Additionally, you can refer to this section of our tracking and importing conversions guide in order to avoid validation errors when uploading conversions and ensure that your requests are successful. I hope this helps.

Thanks and regards,
Peter
Google Ads API Team

ref:_00D1U1174p._5001UEHF1R:ref

Richard Atkins

unread,
Jul 31, 2019, 10:06:06 AM7/31/19
to AdWords API and Google Ads API Forum
Thank you very much for this Peter, much appreciated.
I have decided to keep the code simple, so I have wrapped the mutate call in a try/catch and can then log the success and failures that way - because the SOAP response 'message' tag is available in the exception directly. If you think of a better way to handle that, please let me know. The exception/message is nice and clear :-)
One requirement we have is to log the success/failure of each offline conversion for our own analysis to a GCS bucket and BigQuery.
Thank you again

Google Ads API Forum Advisor Prod

unread,
Jul 31, 2019, 10:13:43 PM7/31/19
to adwor...@googlegroups.com
Hi Richard,

Glad that I was able to help. What you have implemented should already be correct. Feel free to write back anytime if you have additional clarifications.

Best regards,
Reply all
Reply to author
Forward
0 new messages