Google Ads API 支援將 Google Ads 帳戶連結至其他產品帳戶。本指南說明如何使用 API 連結帳戶。
連結帳戶的方式
將 Google Ads 帳戶連結至其他產品帳戶時,有兩種不同的連結方式。
邀請流程
如果您有 Google Ads 帳戶的管理員存取權,但沒有產品帳戶的管理員存取權,請使用邀請流程。這個流程適用於以下兩種情況:
- 您想連結這兩個帳戶,並為產品帳戶的管理員建立邀請。產品帳戶管理員接受邀請,完成帳戶連結程序。
- 產品帳戶管理員想連結這兩個帳戶,但沒有 Google Ads 帳戶的存取權。產品帳戶管理員會建立邀請,您接受邀請後,即可完成連結程序。
在這個情境中,請使用下列方法:
| 情境 | 動作 | 附註 |
|---|---|---|
| Scenario 1 | 建立邀請 | 使用
ProductLinkInvitationService.CreateProductLinkInvitation 方法建立邀請。請勿設定
ProductLinkInvitation 的 status,Google Ads API 伺服器會在 API 呼叫成功完成後,將其設為 REQUESTED。為廣告合作夥伴 (AdvertisingPartnerLinkInvitationIdentifier) 建立邀請時,自 v25 起必須提供 advertising_partner_properties.allowed_domain (在 v24 及更早版本中為選用)。 |
| 檢查邀請狀態 | 使用 GoogleAdsService.Search 或 GoogleAdsService.SearchStream 查詢 product_link_invitation 資源並檢查其狀態。 |
|
| Scenario 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。