我正在玩投标景观,正如官方文档所描述的那样:
借助出价情境,您可以研究有关广告组和条件的估算效果的信息。
我正在 AdGroup 级别测试 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: %dn",
$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/02/08,则 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中为出价环境设置日期范围吗?
我在Google网上论坛中发布了完全相同的问题。Google AdWords API团队是这样回应的:
您无法设置BidLandScape的日期范围。系统根据最新数据进行计算,通常持续 7 天,具体取决于数据可用性。BidLandscape类似于UI中的出价模拟器。你可以看看这个讨论过BidLandScape的帖子。