使用 Amazon Pinpoint 分析搭配 Amazon Cognito 使用者集區 - Amazon Cognito

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 Amazon Pinpoint 分析搭配 Amazon Cognito 使用者集區

Amazon Cognito 使用者集區與 Amazon Pinpoint 整合,以提供 Amazon Cognito 使用者集區的分析,並且讓 Amazon Pinpoint 行銷活動的使用者資料更豐富。Amazon Pinpoint 提供分析和目標性的活動,以透過推送通知來鼓勵使用者使用行動應用程式。透過 Amazon Cognito 使用者集區中的 Amazon Pinpoint 分析支援,可讓您在 Amazon Pinpoint 主控台中追蹤使用者集區註冊、登入、失敗的身分驗證、每日作用中使用者 (DAU) 和每月作用中使用者 (MAU)。您可以深入查看不同日期範圍或屬性的資料,例如裝置平台、裝置地區設定和應用程式版本。

您也可以為應用程式設定自訂屬性。然後您可以在 Amazon Pinpoint 中使用這些屬性來區隔使用者,並傳送目標性的推送通知給他們。如果您在 Amazon Cognito 主控台的 Analytics (分析) 索引標籤,選擇 Share user attribute data with Amazon Pinpoint (與 Amazon Pinpoint 共用使用者屬性資料),將會為使用者電子郵件地址和電話號碼建立額外的端點。

當您在 Amazon Cognito 主控台的使用者集區中啟用 Amazon Pinpoint 分析時,您同時會建立服務連結角色,當 Amazon Cognito 向 Amazon Pinpoint 為您的使用者集區發出 API 請求時假設為該角色。新增分析組態的 IAM 主體必須具有CreateServiceLinkedRole許可。服務連結角色為AWSServiceRoleForAmazonCognitoIdp。如需詳細資訊,請參閱 使用 Amazon Cognito 的服務連結角色

當您在 Amazon Cognito API 中將 AnalyticsConfiguration 套用至應用程式用戶端時,您可以為 Amazon Pinpoint 指派自訂 IAM 角色,並指派外部 ID 來擔任該角色。該角色必須信任 cognito-idp 服務主體,而且如果角色信任原則需要外部 ID,則必須符合您的 AnalyticsConfiguration。您必須為 Amazon Pinpoint 專案授予角色權限和下列權限。

  • mobiletargeting:UpdateEndpoint

  • mobiletargeting:PutEvents

Amazon Cognito 和 Amazon Pinpoint 區域可用性

下表顯示符合下列條件之一的 Amazon Cognito 和 Amazon Pinpoint 之間的 AWS 區域 對應。

  • 您只能使用位於美國東部 (維吉尼亞北部) (us-east-1) 區域的 Amazon Pinpoint 專案。

  • 您可以使用位於同一區域位於美國東部 (維吉尼亞北部) (us-east-1) 區域的 Amazon Pinpoint 專案

Amazon Cognito 預設只能將分析傳送至相同 AWS 區域的 Amazon Pinpoint 專案。此規則的例外是下表中的區域,以及無法使用 Amazon Pinpoint 的區域。

下列區域無法使用 Amazon Pinpoint。這些區域中的 Amazon Cognito 使用者集區不支援分析。

  • 歐洲 (米蘭)

  • Middle East (Bahrain)

  • 亞太區域 (大阪)

  • 以色列 (特拉維夫)

  • 非洲 (開普敦)

  • 亞太區域 (雅加達)

表格顯示您建置 Amazon Cognito 使用者集區的區域與 Amazon Pinpoint 對應區域的關係。您必須在可用區域中設定 Amazon Pinpoint 專案,才能將其與 Amazon Cognito 整合。

Amazon Cognito 使用者集區區域 Amazon Pinpoint 專案區域

ap-northeast-1

us-east-1

ap-northeast-2

us-east-1

ap-south-1

us-east-1、ap-south-1

ap-southeast-1

us-east-1

ap-southeast-2

us-east-1、ap-southeast-2

ca-central-1

us-east-1

eu-central-1

us-est-1、eu-central-1

eu-west-1

us-est-1、eu-west-1

eu-west-2

us-east-1

us-east-1

us-east-1

us-east-2

us-east-1

us-west-2

us-est-1、us-west-2

區域映射範例

  • 如果您在 ap-northeast-1 中建立使用者集區,可以在 us-east-1 中建立您的 Amazon Pinpoint 專案。

  • 如果您在 ap-south-1 中建立使用者集區,可以在 us-east-1 或 ap-south-1 中建立您的 Amazon Pinpoint 專案。

注意

對於 AWS 區域 除上表以外的所有項目,Amazon Cognito 只能在與您的使用者集區位於相同區域中使用 Amazon Pinpoint 專案。如果您建立使用者集區的所在區域無法使用 Amazon Pinpoint,並且沒有列在表中,則 Amazon Cognito 不會支援該區域中的 Amazon Pinpoint 分析。如需詳細的 AWS 區域 資訊,請參閱 Amazon Pinpoint 端點和配額

指定 Amazon Pinpoint 分析設定 (AWS Management Console)

您可以設定 Amazon Cognito 使用者集區,將分析資料傳送到 Amazon Pinpoint。Amazon Cognito 只會針對本機使用者將分析資料傳送至 Amazon Pinpoint。將使用者集區設定為與 Amazon Pinpoint 專案關聯之後,您必須在 API 請求中加入 AnalyticsMetadata。如需詳細資訊,請參閱 將您的應用程式與 Amazon Pinpoint 整合

指定分析設定
  1. 前往 Amazon Cognito 主控台。您可能會收到提示,要求您輸入 AWS 憑證。

  2. 選擇使用者集區,並從清單中選擇現有使用者集區。

  3. 選擇 App integration (應用程式整合) 標籤。

  4. App clients and analytics (應用程式用戶端和分析) 下,從清單中選擇現有的 App client name (應用程式用戶端名稱)。

  5. Pinpoint analytics (Pinpoint 分析) 下,選擇 Enable (啟用)。

  6. 選擇 Pinpoint Region (Pinpoint 區域)。

  7. 選擇 Amazon Pinpoint project (Amazon Pinpoint 專案),或選取 Create Amazon Pinpoint project (建立 Amazon Pinpoint 專案)。

    注意

    Amazon Pinpoint 專案 ID 是 Amazon Pinpoint 專案專屬的 32 字元字串。它會列示在 Amazon Pinpoint 主控台中。

    您可以將多個 Amazon Cognito 應用程式對應至單一 Amazon Pinpoint 專案。不過,每個 Amazon Cognito 應用程式都只能對應至一個 Amazon Pinpoint 專案。

    在 Amazon Pinpoint 中,每個專案都應該是單一應用程式。例如,遊戲開發人員有兩個遊戲,即使這兩個遊戲都使用相同的 Amazon Cognito 使用者集區,每個遊戲應該都還是個別的 Amazon Pinpoint 專案。如需 Amazon Pinpoint 專案的詳細資訊,請參閱在 Amazon Pinpoint 中建立專案

  8. 如果您想要讓 Amazon Cognito 傳送電子郵件地址和電話號碼給 Amazon Pinpoint,以為使用者建立額外的端點,請在 User data sharing (使用者資料共用) 下選擇 Share user attribute data with Amazon Pinpoint (與 Amazon Pinpoint 共用使用者資料)。使用者的電子郵件地址和電話號碼經過驗證後,只有在使用者帳戶可以使用這些資訊的情況下,Amazon Cognito 才會與 Amazon Pinpoint 共用。

    注意

    端點會唯一識別您可以透過 Amazon Pinpoint 來傳送推送通知的使用者裝置。如需端點的詳細資訊,請參閱 Amazon Pinpoint 開發人員指南中的新增端點

  9. 選擇 Save changes (儲存變更)

指定 Amazon Pinpoint 分析設定 (AWS CLI 和 AWS API)

使用下列命令來為您的使用者集區指定 Amazon Pinpoint 分析設定。

在建立應用程式時,為使用者集區現有的用戶端應用程式指定分析設定
為使用者集區現有的用戶端應用程式更新分析設定
注意

在您使用 ApplicationArn 時,Amazon Cognito 支援區域內整合

將您的應用程式與 Amazon Pinpoint 整合

您可以在使用者集區 API 中為 Amazon Cognito 本機使用者將分析中繼資料發布到 Amazon Pinpoint。

本機使用者

註冊帳戶或在您的使用者集區中建立,而非透過第三方身分提供者 (IdP) 登入的使用者。

使用者集區 API

您可以使用具有自定義用戶界面(UI)的應用程序與 AWS SDK 集成的操作。您無法為透過託管 UI 登入的聯合或本機使用者傳遞分析中繼資料。如需使用者集區 API 操作的清單,請參閱 Amazon Cognito API 參考

將使用者集區設定為發佈到行銷活動後,Amazon Cognito 會將中繼資料傳遞至 Amazon Pinpoint,以進行下列 API 操作。

  • AdminInitiateAuth

  • AdminRespondToAuthChallenge

  • ConfirmForgotPassword

  • ConfirmSignUp

  • ForgotPassword

  • InitiateAuth

  • ResendConfirmationCode

  • RespondToAuthChallenge

  • SignUp

若要將使用者工作階段的中繼資料傳遞至 Amazon Pinpoint 促銷活動,請在 API 請求的 AnalyticsMetadata 參數中包括 AnalyticsEndpointId 值。如需 JavaScript 範例,請參閱為什麼我的 Amazon Cognito 使用者集區分析沒有出現在我的 Amazon Pinpoint 儀表板上? 在AWS 知識中心