連結產品帳戶

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 已存在待處理的邀請,因此無法建立連結。

AccountLinkService 異動

如果您使用 AccountLinkService 將 Google Ads 帳戶連結至其他產品帳戶,就必須將現有應用程式遷移至上述任一工作流程。針對下列連結類型,請停用 AccountLinkService 並使用 ProductLinkService

  • GoogleAdsIdentifier
  • MerchantCenterIdentifier
  • AdvertisingPartnerIdentifier

如為 ThirdPartyAppAnalyticsLinkIdentifier,請繼續使用 AccountLinkService