关联产品账号

Google Ads API 支持将 Google Ads 账号与其他产品账号相关联。 本指南介绍了如何使用该 API 关联您的账号。

将 Google Ads 账号与其他产品账号相关联时,关联方式有两种。

邀请流程

当您拥有 Google Ads 账号的管理员访问权限,但没有产品账号的管理员访问权限时,可以使用邀请流程。此流程适用于以下两种情况:

  1. 您想要关联这两个账号,并为产品账号的管理员创建邀请。产品账号管理员接受邀请,以完成账号关联过程。
  2. 产品账号管理员想要关联这两个账号,但没有 Google Ads 账号的访问权限。产品账号管理员创建邀请,您接受邀请并完成账号关联过程。

在此场景中,会使用以下方法:

场景 操作 备注
场景 1 创建邀请 使用 ProductLinkInvitationService.CreateProductLinkInvitation 方法 创建邀请。不应设置 ProductLinkInvitationstatus ;Google Ads API 服务器 会在成功完成 API 调用后将其设置为 REQUESTED
检查邀请的状态 使用 GoogleAdsService.SearchGoogleAdsService.SearchStream 查询 product_link_invitation 资源并检查其状态。
场景 2 检索邀请 使用 GoogleAdsService.SearchGoogleAdsService.SearchStream 查询 product_link_invitation 资源。过滤 status = PENDING_APPROVAL 以接受或拒绝 待处理的邀请。
接受或拒绝邀请 使用 ProductLinkInvitationService.UpdateProductLinkInvitation 方法将 ProductLinkInvitation 的状态更新为 ACCEPTEDREJECTED
撤销邀请 使用 ProductLinkInvitationService.RemoveProductLinkInvitation 方法撤销现有的 ProductLinkInvitation

在此工作流程中,可能会抛出以下常见错误:

错误代码 说明
ProductLinkInvitationError.PERMISSION_DENIED 客户无权执行此操作。
ProductLinkError.NO_INVITATION_REQUIRED 由于用户已拥有受邀账号的管理员 访问权限,因此无法创建邀请。用户应使用 ProductLinkService 直接创建有效关联。

直接关联流程

当您同时拥有 Google Ads 账号和产品账号的管理员访问权限时,可以使用直接关联流程。在这种情况下,您可以将 Google Ads 账号直接关联到产品账号,而无需发送邀请。

在此场景中,会使用以下方法:

操作 备注
创建有效关联 使用 ProductLinkService.createProductLink 创建 ProductLink
停用有效关联 使用 ProductLinkService.removeProductLink 移除有效的 ProductLink
检索有效关联 使用 GoogleAdsService.SearchGoogleAdsService.SearchStream 查询 product_link 资源。

在此工作流程中,可能会抛出以下常见错误:

错误代码 说明
ProductLinkError.CREATION_NOT_PERMITTED 系统尝试使用直接关联流程进行账号关联,但由于缺少权限,因此不支持此操作。用户应改用 ProductLinkInvitationService 执行邀请流程。
ProductLinkError.INVITATION_EXISTS 由于存在待处理的邀请,因此无法创建关联。

您可以使用针对 product_link 资源的 GAQL 查询检索与您的 Google Ads 账号关联的所有产品关联。

    SELECT
      product_link.product_link_id,
      product_link.type
    FROM product_link

product_link.type 字段表示关联的产品或服务的类型。根据 type 的不同,product_link 资源中的其他字段会填充相应的值,以提供有关关联的更多详细信息。例如,如果类型为 THIRD_PARTY_APP_ANALYTICS,则 third_party_app_analytics 字段将包含有关分析提供商的信息。

这样,您就可以获取直接关联到您的 Google Ads 账号的外部服务和应用的列表,例如 Google Play、数据合作伙伴或第三方应用分析平台。

AccountLinkService 的更改

如果您使用 AccountLinkService 将 Google Ads 账号与其他产品账号相关联,则必须将现有应用迁移到前面列出的其中一个工作流程。对于以下关联类型,请迁移出 AccountLinkService 并使用 ProductLinkService

  • GoogleAdsIdentifier
  • MerchantCenterIdentifier
  • AdvertisingPartnerIdentifier

对于 ThirdPartyAppAnalyticsLinkIdentifier,请继续使用 AccountLinkService