推广API和MCC账户以及如何在报表中添加客户ID

2024-10-02 22:33:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是python广告词api v201402。在

我有一个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

如何添加客户id?我尝试在哈希中添加“clientCustomerId”:“xxx xxx xxx”,但得到了以下结果:

^{pr2}$

Tags: inselfreportapiidgetperformance账户
3条回答

请确保您的Googleads.yaml文件已正确配置并位于主目录中。我遇到了一个类似的错误,它修复了它。在

这有点晚,但希望这能帮助其他人在这个问题上绊倒。在

如果您有多个客户机,需要在yaml外部显式设置clientCustomerId,在有一个MCC但有多个客户机的情况下,可以执行以下操作:

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

之后,您可以根据需要使用报表下载器,并且可以根据需要重新分配客户ID。在

clientCustomerId是在API客户机对象中设置的。在

根据您的目标,您应该在配置文件中或在您的client方法中设置此值。在

相关问题 更多 >