1

当我尝试使用 BING-PHP-SDK 发送离线转化数据时,我遇到了 Bing Ads 离线转化数据导入问题。根据响应,PartialErros 为,但数据在 Bing Ad UI 上不可见。但是当我使用 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);
}

注意:在您发送 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>
4

2 回答 2

2

我在这里回答了同样的问题:

https://social.msdn.microsoft.com/Forums/en-US/47b17c14-27fd-45ac-98b8-ca7e28234002/bing-ads-api-v11-connect-issue?forum=BingAds

请让我知道,如果你有任何问题。

于 2017-08-02T16:02:12.407 回答
0

在使用这种方法上传离线转换,我也面临同样的问题。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)
于 2021-02-03T09:03:16.830 回答