关联产品账号

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

将 Google Ads 账号与其他产品账号相关联时,可以通过两种不同的方式进行关联。

邀请流程

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

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

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

场景 操作 备注
场景 1 创建邀请 使用 ProductLinkInvitationService.CreateProductLinkInvitation 方法创建邀请。不应设置 ProductLinkInvitation 的 status;Google Ads API 服务器会在 API 调用成功完成后将此属性设置为 REQUESTED。为广告合作伙伴 (AdvertisingPartnerLinkInvitationIdentifier) 创建邀请时,advertising_partner_properties.allowed_domain 从 v25 开始是必需的(在 v24 及更早版本中是可选的)。
查看邀请的状态 使用 GoogleAdsService.Search 或 GoogleAdsService.SearchStream 查询 product_link_invitation 资源并检查其状态。
场景 2 检索邀请 使用 GoogleAdsService.Search 或 GoogleAdsService.SearchStream 查询 product_link_invitation 资源。过滤 status = PENDING_APPROVAL 以接受或拒绝待处理的邀请。
接受或拒绝邀请 使用 ProductLinkInvitationService.UpdateProductLinkInvitation 方法将 ProductLinkInvitation 的状态更新为 ACCEPTED 或 REJECTED。
撤消邀请 使用 ProductLinkInvitationService.RemoveProductLinkInvitation 方法撤消现有 ProductLinkInvitation。

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

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

直接链接流程

如果您对 Google Ads 账号和产品账号都拥有管理员访问权限,请使用直接关联流程。在这种情况下,请直接将 Google Ads 账号与产品账号相关联,而不是发送邀请。

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

操作 备注
创建有效链接 使用 ProductLinkService.CreateProductLink 创建 ProductLink。
停用有效链接 使用 ProductLinkService.RemoveProductLink 移除有效的 ProductLink。
检索有效链接 使用 GoogleAdsService.Search 或 GoogleAdsService.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 资源中的其他字段,从而提供有关链接的更多详细信息。例如,如果类型为 DATA_PARTNER,则 data_partner 字段将包含有关关联的数据合作伙伴账号的信息。

此方法可让您获取直接与您的 Google Ads 账号相关联的外部服务和产品账号的列表,例如 Merchant Center、Google Ads、广告合作伙伴或数据合作伙伴。

对 AccountLinkService 的更改

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

对于 ThirdPartyAppAnalyticsLinkIdentifier,请继续使用 AccountLinkService。