通过Google Ads API获取出价结果模拟结果

问题描述

我一直在尝试通过API在Google广告中的出价模拟器中获取结果,但未成功。我试图按照Google在这些指南中概述的步骤进行操作:

https://support.google.com/google-ads/answer/9634060?hl=en https://developers.google.com/adwords/api/docs/guides/bid-landscapes#python_3

我对代码进行了很小的修改,它确实可以运行:

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中相同的模拟器输出

有什么想法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)