简体   繁体   English

adwords api和MCC帐户以及如何在报告中添加客户ID

[英]adwords api and MCC account and how to add customer ID in report

I am using the python adwords api v201402. 我正在使用python adwords api v201402。

I have an mcc account. 我有一个mcc帐户。

        report_downloader = self.client.GetReportDownloader(version='v201402')
        # Create report definition.
        report = {
            'reportName': 'Last 7 days CRITERIA_PERFORMANCE_REPORT',
            'dateRangeType': 'LAST_7_DAYS',
            'reportType': 'CRITERIA_PERFORMANCE_REPORT',
            'downloadFormat': 'CSV',
            'selector': {
                'fields': ['CampaignId', 'AdGroupId', 'Id', 'CriteriaType',
                           'Criteria', 'Impressions', 'Clicks', 'Cost']
            },
            # Enable to get rows with zero impressions.
            'includeZeroImpressions': 'false'
        }

If I dont add a customer ID I get the below error:
    output, return_money_in_micros)
  File "/usr/local/lib/python2.7/dist-packages/googleads-1.0.1-py2.7.egg/googleads/adwords.py", line 406, in _DownloadReport
    raise self._ExtractError(e)
googleads.errors.AdWordsReportBadRequestError: Type: AuthenticationError.CLIENT_CUSTOMER_ID_INVALID
Trigger: <null>
Field Path: None

How do I add a customer id? 如何添加客户ID? I tried adding 'clientCustomerId':"xxx-xxx-xxx" in the hash but I get the below: 我尝试在哈希中添加'clientCustomerId':“xxx-xxx-xxx”,但我得到以下内容:

  File "/usr/local/lib/python2.7/dist-packages/suds_jurko-0.6-py2.7.egg/suds/mx/core.py", line 71, in append
    if self.start(content):
  File "/usr/local/lib/python2.7/dist-packages/suds_jurko-0.6-py2.7.egg/suds/mx/literal.py", line 86, in start
    raise TypeNotFound(content.tag)
suds.TypeNotFound: Type not found: 'clientCustomerId'

The clientCustomerId is set within your API client object. clientCustomerId在您的API客户端对象中设置。

Depending on your goals, you should either set this value in a config file, or in your client method. 根据您的目标,您应该在配置文件中或在client方法中设置此值。

This is a bit late, but hopefully this might help others stumbling onto this question. 这有点晚了,但希望这可能会帮助其他人绊倒这个问题。

If you have multiple clients for whom you need to explicitly set the clientCustomerId outside of your yaml, in the instance where you have one MCC but multiple clients, you can do the following: 如果您有多个客户端,您需要在yaml之外明确设置clientCustomerId,在您有一个MCC但多个客户端的实例中,您可以执行以下操作:

self.client = AdWordsClient.LoadFromStorage()
self.client.SetClientCustomerId(<client_customer_id>)

After that, you can use the report downloader as needed, and you can re-assign the customer ID as needed. 之后,您可以根据需要使用报告下载程序,并根据需要重新分配客户ID。

Make sure your Googleads.yaml file is configured correctly and in your home directory. 确保您的Googleads.yaml文件已正确配置并位于您的主目录中。 I got a similar error and that fixed it. 我得到了类似的错误并修复了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM