当我尝试使用BING-PHP-SDK发送离线转化数据时,我遇到Bing Ads离线转化数据导入问题。在空 PartialErros上进行回复,但在Bing广告用户界面上看不到数据。但是,当我使用CSV离线转化上传功能时,一切正常。
来自Bing API调用的响应:
stdClass Object
(
[PartialErrors] => stdClass Object
(
)
)
使用的代码:
AuthHelper::AuthenticateWithOAuth();
$GLOBALS['CustomerProxy'] = new ServiceClient(ServiceClientType::CustomerManagementVersion11,
$GLOBALS['AuthorizationData'], AuthHelper::GetApiEnvironment());
$user = CustomerManagementHelper::GetUser(null)->User;
#AccountId and CustomerId parsing code goes here
//parse $user to set AccountId
$GLOBALS['AuthorizationData']->AccountId = $obj->Id;
//parse $user to set CustomerId header
$GLOBALS['AuthorizationData']->CustomerId = $obj->ParentCustomerId;
$GLOBALS['CampaignProxy'] = new ServiceClient(ServiceClientType::CampaignManagementVersion11, $GLOBALS['AuthorizationData'], AuthHelper::GetApiEnvironment());
//send offline conversion
$offline =[];
$offline = new OfflineConversion();
$offline->ConversionCurrencyCode = 'USD';
$offline->ConversionName = 'OfflineConversionSellOfRentals';
$offline->ConversionTime = date('Y-m-d\TH:i:s', strtotime('-7 days'));
$offline->ConversionValue = 2.5;
$offline->MicrosoftClickId = '8349a6501442491186ce602ca56881fe';
$request[] = $offline;
$offline_response = CampaignManagementHelper::ApplyOfflineConversions($request);
print_r($offline_response);
在 CampaignManagementHelper.php 文件
中创建了一个方法static function AddOfflineConversions($offline){
$GLOBALS['Proxy'] = $GLOBALS['CampaignProxy'];
$request = new ApplyOfflineConversionsRequest();
$request->OfflineConversions = $offline;
return $GLOBALS['CampaignProxy']->GetService()->ApplyOfflineConversions($request);
}
N.B:向Bing Ads发送离线转化后,查看转化数据最多可能需要五个小时(来自api文档,这是原因吗?)
修改
请求:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="https://bingads.microsoft.com/CampaignManagement/v11">
<SOAP-ENV:Header>
<ns1:CustomerAccountId>#########</ns1:CustomerAccountId>
<ns1:CustomerId>#########</ns1:CustomerId>
<ns1:DeveloperToken>#########</ns1:DeveloperToken>
<ns1:UserName/>
<ns1:Password/>
<ns1:AuthenticationToken>
#########
</ns1:AuthenticationToken>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:ApplyOfflineConversionsRequest>
<ns1:OfflineConversions>
<ns1:OfflineConversion>
<ns1:ConversionCurrencyCode>USD</ns1:ConversionCurrencyCode>
<ns1:ConversionName>Offline Conversion Goal</ns1:ConversionName>
<ns1:ConversionTime>2017-08-01T14:00:24</ns1:ConversionTime>
<ns1:ConversionValue>1</ns1:ConversionValue>
<ns1:MicrosoftClickId>#########</ns1:MicrosoftClickId>
</ns1:OfflineConversion>
</ns1:OfflineConversions>
</ns1:ApplyOfflineConversionsRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
响应:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<h:TrackingId xmlns:h="https://bingads.microsoft.com/CampaignManagement/v11">
##########
</h:TrackingId>
</s:Header>
<s:Body>
<ApplyOfflineConversionsResponse xmlns="https://bingads.microsoft.com/CampaignManagement/v11">
<PartialErrors xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>
</ApplyOfflineConversionsResponse>
</s:Body>
</s:Envelope>
答案 0 :(得分:2)
我在这里回答了同样的问题:
如果您有任何疑问,请与我们联系。
答案 1 :(得分:0)
我在使用 https://github.com/BingAds/BingAds-Python-SDK 时也面临同样的问题 使用此方法上传离线转换时。 campaign_service.ApplyOfflineConversions。
根据响应,有一个空的 PartialErros 但数据在 Microsoft 帐户中不可见。
offline_conversions=campaign_service.factory.create('ArrayOfOfflineConversion')
offline_conversion=set_elements_to_none(campaign_service.factory.create('OfflineConversion'))
# If you do not specify an offline conversion currency code,
# then the 'CurrencyCode' element of the goal's 'ConversionGoalRevenue' is used.
offline_conversion.ConversionCurrencyCode = "INR"
# The conversion name must match the 'Name' of the 'OfflineConversionGoal'.
# If it does not match you won't observe any error, although the offline
# conversion will not be counted.
offline_conversion.ConversionName = offline_conversion_goal_name
# The date and time must be in UTC, should align to the date and time of the
# recorded click (MicrosoftClickId), and cannot be in the future.
print("==============time")
print(datetime.utcnow())
print(datetime.utcnow() - timedelta(hours=0, minutes=2))
offline_conversion.ConversionTime = (datetime.utcnow() - timedelta(hours=0, minutes=10))
# offline_conversion.ConversionTime = datetime.utcnow()
# If you do not specify an offline conversion value,
# then the 'Value' element of the goal's 'ConversionGoalRevenue' is used.
offline_conversion.ConversionValue = 5
offline_conversion.MicrosoftClickId = "bb3084024ed412a83006e41b6bbf693a"
# offline_conversion.wc_clear=true
offline_conversions.OfflineConversion.append(offline_conversion)
print(offline_conversions)
# After the OfflineConversionGoal is set up, wait two hours before sending Bing Ads the offline conversions.
# This example would not succeed in production because we created the goal very recently i.e.,
# please see above call to AddConversionGoals.
output_status_message("-----\nApplyOfflineConversions:")
apply_offline_conversions_response = campaign_service.ApplyOfflineConversions(
OfflineConversions=offline_conversions)
print(apply_offline_conversions_response)
output_status_message("PartialErrors:")
output_array_of_batcherror(apply_offline_conversions_response)