0

我玩Bid Landscapes,並作爲官方文件描述:如何設置出價競爭的日期範圍 - AdWords API的

的出價前景是您研究有關廣告組估計的性能信息的方法和標準。

我測試在廣告組級別的API,下面這段代碼已被寫入:

public function test_bid_simulator() { 
    $user = new AdWordsUser(); 
    $user->SetClientCustomerId('*******'); 
    $dataService = $user->GetService('DataService', 'v201509'); 

    $selector = new Selector(); 
    $selector->fields = array('AdGroupId', 'StartDate', 'EndDate', 
     'Bid', 'LocalClicks', 'LocalCost', 'LocalImpressions'); 

    // Create predicates. 
    $selector->predicates[] = new Predicate('CampaignId', 'IN', array('****', '****', '****', '****')); 

    // $selector->dateRange = new DateRange(); 
    // $selector->dateRange->min = date('Ymd', strtotime('2016/01/28')); 
    // $selector->dateRange->max = date('Ymd', strtotime('2016/02/03')); 

    do { 
     // Make the getAdGroupBidLandscape request. 
     $page = $dataService->getAdGroupBidLandscape($selector); 

     // Display results. 
     if (isset($page->entries)) { 
      foreach ($page->entries as $bidLandscape) { 
       printf("Found adgroup bid landscape with id '%s' for start " 
         . "date '%s', end date '%s', and landscape points:\n", 
         $bidLandscape->adGroupId, 
         $bidLandscape->startDate, 
         $bidLandscape->endDate); 
       foreach ($bidLandscape->landscapePoints as $bidLandscapePoint) { 
        printf(" bid: %.0f => clicks: %d, cost: %.0f, impressions: %d\n", 
          $bidLandscapePoint->bid->microAmount, 
          $bidLandscapePoint->clicks, 
          $bidLandscapePoint->cost->microAmount, 
          $bidLandscapePoint->impressions); 
       } 
       print "\n"; 
      } 
     } 
     // Advance the paging index. 
     $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE; 
    } while (isset($page->entries) && count($page->entries) > 0); 

    if ($selector->paging->startIndex === 0) { 
     print "No adgroup bid landscapes were found.\n"; 
    } 
} 

此代碼工作正常,輸出是類似於:

Found adgroup bid landscape with id '****' for start date '20160131', end date '20160206', and landscape points: 
    bid: 60000 => clicks: 0, cost: 0, impressions: 38 
    bid: 110000 => clicks: 0, cost: 0, impressions: 70 
    bid: 150000 => clicks: 0, cost: 0, impressions: 97 
    bid: 210000 => clicks: 0, cost: 0, impressions: 116 
    bid: 280000 => clicks: 0, cost: 0, impressions: 126 
    bid: 470000 => clicks: 0, cost: 0, impressions: 136 

Found adgroup bid landscape with id '****' for start date '20160131', end date '20160206', and landscape points: 
    bid: 20000 => clicks: 0, cost: 0, impressions: 16 
    bid: 40000 => clicks: 0, cost: 0, impressions: 89 
    bid: 60000 => clicks: 0, cost: 0, impressions: 138 
    bid: 100000 => clicks: 0, cost: 0, impressions: 183 
    bid: 160000 => clicks: 0, cost: 0, impressions: 218 
    bid: 240000 => clicks: 0, cost: 0, impressions: 234 
    bid: 390000 => clicks: 0, cost: 0, impressions: 256 

etc. 

默認情況下,API始終會提取從現在起兩天後的前一週範圍。例如,如果今天是2016年2月8日,API將獲得2016/01/31至2016/02/06之間的範圍。我的問題是如何在代碼中設置特定的日期範圍。我已經註釋掉這部分

// $selector->dateRange = new DateRange(); 
// $selector->dateRange->min = date('Ymd', strtotime('2016/01/01')); 
// $selector->dateRange->max = date('Ymd', strtotime('2016/01/31')); 

因爲它不起作用。如果我取消註釋這部分,代碼不會給我任何結果。有關如何爲Adwords API中的出價格局設置日期範圍的任何知識?

回答

0

我已經在Google Groups中發佈了完全相同的問題。這就是Google AdWords API團隊的迴應方式:

您無法爲BidLandScape設置日期範圍。系統根據最新數據進行計算,通常爲7天,取決於數據的可用性。 BidLandscape與UI中的出價模擬器相似。您可以看看關於BidLandScape的thread