Python 通过谷歌广告API获取竞价模拟结果
我一直试图通过API从谷歌广告中的竞价模拟器中获得结果,但没有成功。我试着遵循谷歌在这些指南中概述的步骤: 我稍微修改了代码,它确实运行:Python 通过谷歌广告API获取竞价模拟结果,python,google-ads-api,Python,Google Ads Api,我一直试图通过API从谷歌广告中的竞价模拟器中获得结果,但没有成功。我试着遵循谷歌在这些指南中概述的步骤: 我稍微修改了代码,它确实运行: from googleads import adwords CAMPAIGN_ID = '---------' PAGE_SIZE = 100 def main(client, campaign_id): # Initialize appropriate service. data_service = client.GetServi
from googleads import adwords
CAMPAIGN_ID = '---------'
PAGE_SIZE = 100
def main(client, campaign_id):
# Initialize appropriate service.
data_service = client.GetService('DataService', version='v201809')
# Get all the campaigns for this account.
selector = {
'fields': ['CampaignId', 'CriterionId', 'StartDate', 'EndDate',
'BidModifier', 'LocalClicks', 'LocalCost', 'LocalImpressions',
'TotalLocalClicks', 'TotalLocalCost', 'TotalLocalImpressions',
'RequiredBudget'],
'paging': {
'startIndex': 0,
'numberResults': PAGE_SIZE
},
'predicates': [{
'field': 'CampaignId', 'operator': 'IN', 'values': [campaign_id]
}]
}
# Set initial values.
offset = 0
more_pages = True
while more_pages is True:
num_landscape_points = 0
page = data_service.getCampaignCriterionBidLandscape(selector)
# Display results.
if 'entries' in page:
for bid_modifier_landscape in page['entries']:
num_landscape_points = 0
print(f'Found campaign-level criterion bid modifier landscapes for '
f"criterion with ID {bid_modifier_landscape['criterionId']},"
f" start date {bid_modifier_landscape['startDate']}, end date {bid_modifier_landscape['endDate']},"
f" and landscape points:")
for landscape_point in bid_modifier_landscape['landscapePoints']:
num_landscape_points += 1
print(f"\tbid modifier: {landscape_point['bidModifier']},"
f" clicks: {landscape_point['clicks']},"
f" cost: {landscape_point['cost']['microAmount']},"
f" impressions: {landscape_point['impressions']},"
f"total clicks: {landscape_point['totalLocalClicks']},"
f" total cost: {landscape_point['totalLocalCost']['microAmount']},"
f" total impressions: {landscape_point['totalLocalImpressions']},"
f"and required budget: {landscape_point['requiredBudget']['microAmount']}")
else:
print('No bid modifier landscapes found.')
# Need to increment by the total # of landscape points within the page,
# NOT the number of entries (bid landscapes) in the page.
offset += num_landscape_points
selector['paging']['startIndex'] = str(offset)
more_pages = num_landscape_points >= PAGE_SIZE
if __name__ == '__main__':
# Initialize client object.
adwords_client = adwords.AdWordsClient.LoadFromStorage()
main(adwords_client, CAMPAIGN_ID)
然而,这并没有让我得到预测的转换值,只有点击和印象等,这不是我真正想要的。这似乎与文档相符,但在GUI中,我可以获得转换值,但似乎无论我尝试查询哪个键,API都不会让我获得与GUI中相同的模拟器输出
有什么想法吗