Reminder: v201708 will be sunset on August 31, 2018.

DFP 销售管理系统对帐

本指南阐明了对帐服务,并向您介绍了如何检索和调整您的结算数据和投放数据。

基础入门

在开始使用对帐服务前,请务必对 DFP 广告管理系统(以下简称 DFP)中的对帐流程进行充分了解。下面的图表显示了所示对象之间的关系。 对帐实体

ReconciliationReport

ReconciliationReport 对象表示结算周期的投放数据的顶级父级。ReconciliationReports 有 DRAFTRECONCILEDREVERTED 这 3 种只读的计算状态。相应状态源自 ReconciliationReport 的订单的状态。例如,如果所有 ReconciliationOrderReport 的状态为 RECONCILED,则 ReconciliationReport 的状态也是 RECONCILED

检索 ReconciliationReportRow 或 ReconciliationOrderReport 时必须使用 ReconciliationReport 的 ID。

可修改的字段
ReconciliationReport.notes

ReconciliationOrderReport

ReconciliationOrderReport 表示对帐报表中的一个订单。在查看并调整了相应订单的订单项中的对帐信息后,您可以提交 ReconciliationOrderReport。如果您需要修改投放数据或收入数据,则可以还原 ReconciliationOrderReport。

可修改的字段
ReconciliationOrderReport.proposalGrossBillableRevenueManualAdjustment

ReconciliationLineItemReport

ReconciliationLineItemReport 包含单个订单项在某个结算周期内的投放数据和结算数据。您可以设置第三方广告服务器的投放量、添加手动投放量调整项,也可以完全替换可结算收入。

可修改的字段
ReconciliationLineItemReport.reconciliationSource
ReconciliationLineItemReport.thirdPartyVolume
ReconciliationLineItemReport.manualVolume
ReconciliationLineItemReport.billableRevenueOverrides

ReconciliationReportRow

ReconciliationReportRow 包含广告素材级的投放数据。该对象由其对帐报表、订单项和广告素材唯一标识。它包含一个 thirdPartyVolume 字段(用于输入来自第三方广告服务器的投放信息)和一个 manualVolume 字段(当您需要替换 DFP 或第三方投放量时,可使用该字段)。

可修改的字段
ReconciliationReportRow.billFrom
ReconciliationReportRow.thirdPartyVolume
ReconciliationReportRow.manualVolume
ReconciliationReportRow.comments

检索某个结算周期的投放数据

要检索某个月的对帐报表,您可以按相应报表的开始日期进行过滤。

Java


  ReconciliationReportServiceInterface reconciliationReportService =
      dfpServices.get(session, ReconciliationReportServiceInterface.class);

  // Get the NetworkService.
  NetworkServiceInterface networkService =
      dfpServices.get(session, NetworkServiceInterface.class);

  // Get the first day of last month in your network's time zone.
  Network network = networkService.getCurrentNetwork();
  DateTime lastMonth = new DateTime(DateTimeZone.forID(network.getTimeZone()))
      .minusMonths(1).dayOfMonth().withMinimumValue();

  // Create a statement to select reconciliation reports.
  StatementBuilder statementBuilder = new StatementBuilder()
      .where("startDate = :startDate")
      .orderBy("id ASC")
      .limit(1)
      .withBindVariableValue("startDate", lastMonth.toString("YYYY-MM-dd"));

  // Get the reconciliation report.
  ReconciliationReportPage page =
      reconciliationReportService.getReconciliationReportsByStatement(
          statementBuilder.toStatement());

Python


# Initialize appropriate service.
reconciliation_report_service = client.GetService(
    'ReconciliationReportService', version='v201711')

first_of_the_month = date.today().replace(day=1)
last_month = first_of_the_month - timedelta(days=1)

# Create a statement to select reconciliation reports.
statement = (dfp.StatementBuilder()
             .Where('startDate = :startDate')
             .WithBindVariable('startDate', last_month))

# Retrieve a small amount of reconciliation reports at a time, paging
# through until all reconciliation reports have been retrieved.
while True:
  response = (
      reconciliation_report_service
      .getReconciliationReportsByStatement(
          statement.ToStatement()))
  if 'results' in response:
    for reconciliation_report in response['results']:
      # Print out some information for each reconciliation report.
      print(
          'Reconciliation report with ID "%d" and start date "%s" was found.'
          '\n' % (reconciliation_report['id'],
                  last_month.strftime('%Y-%m-01')))
    statement.offset += dfp.SUGGESTED_PAGE_LIMIT
  else:
    break

PHP


        $reconciliationReportService =
            $dfpServices->get($session, ReconciliationReportService::class);

        $networkService = $dfpServices->get($session, NetworkService::class);
        $network = $networkService->getCurrentNetwork();

        // Create a statement to select reconciliation reports.
        $pageSize = StatementBuilder::SUGGESTED_PAGE_LIMIT;
        $statementBuilder = (new StatementBuilder())->where('startDate = :startDate')
            ->orderBy('id ASC')
            ->limit(
                $pageSize
            )
            ->withBindVariableValue(
                'startDate',
                DfpDateTimes::fromDateTime(
                    new DateTime(
                        'first day of last month',
                        new DateTimeZone($network->getTimeZone())
                    )
                )
                    ->getDate()
            );

          $page = $reconciliationReportService->getReconciliationReportsByStatement(
              $statementBuilder->toStatement()
          );

您可以在其中使用 ReconciliationReport 的 ID 来检索该报表的所有订单、订单项或广告素材。以下示例代码展示了用于检索某一个报表的订单项的过滤器。

Java


  // Create a statement to select reconciliation line item reports.
  StatementBuilder statementBuilder = new StatementBuilder()
      .where("reconciliationReportId = :reconciliationReportId AND lineItemId != :lineItemId")
      .orderBy("lineItemId ASC")
      .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
      .withBindVariableValue("reconciliationReportId", reconciliationReportId)
      .withBindVariableValue("lineItemId", 0);

Python


  # Create a statement to select reconciliation line item reports.
  statement = (dfp.StatementBuilder()
               .Where(('reconciliationReportId = :reconciliationReportId AND '
                       'lineItemId != :lineItemId'))
               .OrderBy('lineItemId', ascending=True)
               .WithBindVariable('reconciliationReportId',
                                 RECONCILIATION_REPORT_ID)
               .WithBindVariable('lineItemId', 0))

PHP


        // Create a statement to select reconciliation line item reports.
        $pageSize = StatementBuilder::SUGGESTED_PAGE_LIMIT;
        $statementBuilder = (new StatementBuilder())->where(
            'reconciliationReportId = :reconciliationReportId AND ' . 'lineItemId != :lineItemId'
        )
            ->orderBy('lineItemId ASC')
            ->limit($pageSize)
            ->withBindVariableValue(
                'reconciliationReportId',
                $reconciliationReportId
            )
            ->withBindVariableValue('lineItemId', 0);

对订单项级收入进行对帐

您可以使用 ReconciliationLineItemReportService 输入订单项级的第三方广告服务器投放数据。如果您需要对 DFP 的投放数据进行对帐,则可以使用手动投放量(如此处所示)。这种方式类似于在 DFP 界面中修改“已对帐投放量”单元格。

Java


  // Set and use a manual volume for billing. This example splits the difference between DFP
  // and the third party volume.
  lineItemReport.setManualVolume(
      (lineItemReport.getDfpVolume() + lineItemReport.getThirdPartyVolume()) / 2);
  lineItemReport.setReconciliationSource(BillFrom.MANUAL);

  ReconciliationLineItemReport[] updatedLineItemReports =
      reconciliationLineItemReportService.updateReconciliationLineItemReports(
          new ReconciliationLineItemReport[] {lineItemReport});

Python


  # Set and use a manual volume for billing. This example splits the difference
  # between DFP and the third party volume.
  line_item_report['manualVolume'] = (line_item_report['dfpVolume'] +
                                      line_item_report['thirdPartyVolume']) / 2
  line_item_report['reconciliationSource'] = 'MANUAL'

  result = (reconciliation_line_item_report_service
            .updateReconciliationLineItemReports([line_item_report]))

PHP


        // Set and use a manual volume for billing. This example splits the
        // difference between DFP and the third party volume.
        $lineItemReport->setManualVolume(
            ($lineItemReport->getDfpVolume() + $lineItemReport->getThirdPartyVolume()) / 2
        );
        $lineItemReport->setReconciliationSource(BillFrom::MANUAL);

        // Update the reconciliation line item report on the server.
        $updatedLineItemReports =
            $reconciliationLineItemReportService->updateReconciliationLineItemReports(
                [$lineItemReport]
            );

某些收入字段的值取决于您的广告联盟、提案和订单项的设置。如需更多信息,请参阅参考文档

替换可结算收入

如果对投放进行调整不足以解决问题,您还可以手动替换可结算收入。为此,请设置 billableRevenueOverride。在对提案订单项进行对帐时,该字段表示总值或净值,具体取决于定价模式。

对广告素材级收入进行对帐

您可以使用 ReconciliationReportRowService 输入广告素材级的第三方广告服务器投放数据或手动投放量。ReconciliationReportRow 由其 reconciliationReportId、lineItemId 和 creativeId 唯一标识,而没有唯一 ID。

Java


  // Get the ReconciliationReportRowService.
  ReconciliationReportRowServiceInterface reconciliationReportRowService =
      dfpServices.get(session, ReconciliationReportRowServiceInterface.class);

  // Create a statement to select reconciliation report rows.
  StatementBuilder statementBuilder = new StatementBuilder()
      .where("id = :reconciliationReportRowId AND "
          + "reconciliationReportId = :reconciliationReportId")
      .orderBy("id ASC")
      .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
      .withBindVariableValue("reconciliationReportRowId", reconciliationReportRowId)
      .withBindVariableValue("reconciliationReportId", reconciliationReportId);

  // Get reconciliation report rows by statement.
  ReconciliationReportRowPage page =
      reconciliationReportRowService.getReconciliationReportRowsByStatement(
          statementBuilder.toStatement());

  ReconciliationReportRow row = Iterables.getOnlyElement(Arrays.asList(page.getResults()));

  // Set a comment on the reconciliation report row.
  row.setComments("Third party volume didn't match DFP - we agreed to split the difference");

  // Set and use a manual volume for billing.
  row.setManualVolume((row.getDfpVolume() + row.getThirdPartyVolume()) / 2);
  row.setReconciliationSource(BillFrom.MANUAL);

  ReconciliationReportRow[] updatedRows =
      reconciliationReportRowService.updateReconciliationReportRows(
          new ReconciliationReportRow[] {row});

Python


  # Initialize appropriate service.
  reconciliation_report_row_service = (client.GetService(
      'ReconciliationReportRowService', version='v201711'))

  # Create a statement to select reconciliation report rows.
  statement = (dfp.StatementBuilder()
               .Where(('id = :reconciliationReportRowId AND '
                       'reconciliationReportId = :reconciliationReportId'))
               .OrderBy('id', ascending=True)
               .WithBindVariable('reconciliationReportRowId',
                                 RECONCILIATION_REPORT_ROW_ID)
               .WithBindVariable('reconciliationReportId',
                                 RECONCILIATION_REPORT_ID))

  # Get reconciliation report rows by statement.
  page = (reconciliation_report_row_service
          .getReconciliationReportRowsByStatement(statement.ToStatement()))

  row = page['results'][0]

  # Set a comment on the reconciliation report row.
  row['comments'] = ('Third part volume didn\'t match DFP - we agreed to split '
                     'the difference')

  # Set and use a manual volume for billing.
  row['manualVolume'] = (row['dfpVolume'] + row['thirdPartyVolume']) / 2
  row['reconciliationSource'] = 'MANUAL'

  updated_rows = (reconciliation_report_row_service
                  .updateReconciliationReportRows([row]))

PHP


        $reconciliationReportRowService = $dfpServices->get(
            $session,
            ReconciliationReportRowService::class
        );

        // Create a statement to select the reconciliation report rows to update.
        $pageSize = StatementBuilder::SUGGESTED_PAGE_LIMIT;
        $statementBuilder = (new StatementBuilder())->where(
            'reconciliationReportId = :reconciliationReportId AND id = '
            . ':reconciliationReportRowId'
        )
            ->orderBy('id ASC')
            ->limit($pageSize)
            ->withBindVariableValue(
                'reconciliationReportId',
                $reconciliationReportId
            )
            ->withBindVariableValue(
                'reconciliationReportRowId',
                $reconciliationReportRowId
            );

        $page = $reconciliationReportRowService->getReconciliationReportRowsByStatement(
            $statementBuilder->toStatement()
        );
        $row = $page->getResults()[0];

        // Set a comment on the reconciliation report row.
        $row->setComments(
            'Third party volume didn\'t match DFP - we agreed to split the difference'
        );

        // Set and use a manual volume for billing.
        $row->setManualVolume(
            ($row->getDfpVolume() + $row->getThirdPartyVolume()) / 2
        );
        $row->setReconciliationSource(BillFrom::MANUAL);

        // Update the reconciliation report rows on the server.
        $updatedRows = $reconciliationReportRowService->updateReconciliationReportRows([$row]);

提交或还原订单的投放数据

在核对过某个订单的投放数据并对其进行对帐后,您可以提交 ReconciliationOrderReport。

Java


  // Get the ReconciliationOrderReportService.
  ReconciliationOrderReportServiceInterface reconciliationOrderReportService =
      dfpServices.get(session, ReconciliationOrderReportServiceInterface.class);

  // Create a statement to select reconciliation order reports.
  StatementBuilder statementBuilder = new StatementBuilder()
      .where("id = :id")
      .orderBy("id ASC")
      .limit(1)
      .withBindVariableValue("id", reconciliationOrderReportId);

  // Create action to submit reconciliation order reports.
  com.google.api.ads.dfp.axis.v201711.SubmitReconciliationOrderReports action =
      new com.google.api.ads.dfp.axis.v201711.SubmitReconciliationOrderReports();

  // Perform action.
  UpdateResult result =
      reconciliationOrderReportService.performReconciliationOrderReportAction(
          action, statementBuilder.toStatement());

Python

  # Initialize appropriate service.
  reconciliation_order_report_service = (client.GetService(
      'ReconciliationOrderReportService', version='v201711'))

  # Create a statement to select reconciliation order reports.
  statement = (dfp.StatementBuilder()
               .Where('id = :id')
               .OrderBy('id', ascending=True)
               .Limit(1)
               .WithBindVariable('id', RECONCILIATION_ORDER_REPORT_ID))

  # Perform action.
  result = (reconciliation_order_report_service
            .performReconciliationOrderReportAction(
                {'xsi_type': 'SubmitReconciliationOrderReports'},
                statement.ToStatement()))

PHP


        $reconciliationOrderReportService =
            $dfpServices->get($session, ReconciliationOrderReportService::class);

        // Create a statement to select the reconciliation order reports to submit.
        $pageSize = StatementBuilder::SUGGESTED_PAGE_LIMIT;
        $statementBuilder = (new StatementBuilder())->where('id = :id')
            ->orderBy('id ASC')
            ->limit($pageSize)
            ->withBindVariableValue('id', $reconciliationOrderReportId);

          // Create and perform action.
          $action = new SubmitReconciliationOrderReportsAction();
          $result = $reconciliationOrderReportService->performReconciliationOrderReportAction(
              $action,
              $statementBuilder->toStatement()
          );

如果您需要对相关数据进行进一步调整,也可以使用 RevertReconciliationOrderReports 操作还原订单报表。

常见问题解答

能否对报表使用对帐服务?

我们强烈建议您使用 ReportService 来检索只读的投放数据和收入数据。有关创建结算和对帐报表的详细信息,请访问 DFP 帮助中心。对帐服务应主要用于审核投放信息并对其进行对帐。

ReconciliationLineItemReport 和 ReconciliationReportRow 之间有何区别?

ReconciliationReportRow 用于处理广告素材级的投放数据,而 ReconciliationLineItemReport 用于处理订单项级的投放数据。

如何提交 ReconciliationReport?

您无法直接提交 ReconciliationReport。提交完所有的 ReconciliationOrderReport 后,对应 ReconciliationReport 的状态将显示为 RECONCILED

投放量字段没有单位。这些字段会代表什么内容?

投放量相关字段的单位取决于 LineItemProposalLineItem 的费率类型。例如,如果 RateType 是 CPC,则该字段代表点击次数;如果费率类型为 CPM,则该字段代表展示次数;如果费率类型为 CPD,则该字段代表订单项的投放天数。

我设置了手动投放量,但已对帐投放量无任何变化。这是怎么回事?

除了设置手动投放量外,您还必须设置结算所依据的投放量

对帐服务和 ReportService 提取的数据之间有何区别?

对帐服务根据提案的本地时区提供投放量和收入数据,而 ReportService 是根据广告联盟时区提供数据。

发送以下问题的反馈:

此网页
DoubleClick for Publishers API
DoubleClick for Publishers API
需要帮助?请访问我们的支持页面