連結產品帳戶

Google Ads API 支援將 Google Ads 帳戶連結至其他產品帳戶。 本指南說明如何使用 API 連結帳戶。

將 Google Ads 帳戶連結至其他產品帳戶時,有兩種不同的連結方式。

邀請流程

如果您有 Google Ads 帳戶的管理員存取權,但沒有產品帳戶的管理員存取權,請使用邀請流程。這個流程適用於兩種情況:

  1. 您想連結這兩個帳戶,並為產品帳戶管理員建立邀請。產品帳戶管理員接受邀請,完成帳戶連結程序。
  2. 產品帳戶管理員想連結這兩個帳戶,但無法存取 Google Ads 帳戶。產品帳戶管理員建立邀請,您接受邀請並完成連結程序。

這個情境會使用下列方法:

情境 動作 附註
情境 1: 建立邀請 使用 ProductLinkInvitationService.CreateProductLinkInvitation 方法建立邀請。status ProductLinkInvitation 不應設定,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