Google Ads API 支持将 Google Ads 账号与其他产品账号相关联。 本指南介绍了如何使用 API 关联账号。
关联账号的方式
将 Google Ads 账号与其他产品账号相关联时,可以通过两种不同的方式进行关联。
邀请流程
如果您拥有 Google Ads 账号的管理员访问权限,但没有产品账号的管理员访问权限,则可以使用邀请流程。此流程适用于以下两种情况:
- 您希望关联这两个账号,并为产品账号的管理员创建邀请。产品账号管理员接受邀请,完成账号关联流程。
- 产品账号管理员想要关联这两个账号,但无权访问 Google Ads 账号。产品账号管理员创建邀请,您接受邀请并完成关联流程。
此方案中使用了以下方法:
| 场景 | 操作 | 备注 | 
|---|---|---|
| 场景 1 | 创建邀请 | 使用 ProductLinkInvitationService.CreateProductLinkInvitation方法
    创建邀请。不应设置ProductLinkInvitation的status;Google Ads API 服务器会在 API 调用成功完成后将此属性设置为REQUESTED。 | 
| 查看邀请的状态 | 使用 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 | 客户无权执行此操作。 | 
| ProductLinkError.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 | 无法创建关联,因为已存在待处理的邀请。 | 
对 AccountLinkService 的更改
如果您使用 AccountLinkService 将 Google Ads 账号与其他产品账号相关联,则必须将现有应用迁移到前面列出的某个工作流。对于以下链接类型,请从 AccountLinkService 迁移并使用 ProductLinkService:
- GoogleAdsIdentifier
- MerchantCenterIdentifier
- AdvertisingPartnerIdentifier
对于 ThirdPartyAppAnalyticsLinkIdentifier,请继续使用 AccountLinkService。