# AnalyticsConfiguration

The settings for Amazon Pinpoint analytics configuration.

With an analytics configuration, your application can collect user-activity metrics for user notifications with an Amazon Pinpoint campaign.
Amazon Pinpoint isn't available in all AWS Regions.
For a list of available Regions, see Amazon Cognito and Amazon Pinpoint Region availability: https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-pinpoint-integration.html#cognito-user-pools-find-region-mappings.

- Source: [`aws-cognito/lib/user-pool-client.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cognito/lib/user-pool-client.ts#L387)
- Type last changed: v2.224.0 · 13 Nov 2025

## Example

TypeScript:

```ts
import * as pinpoint from 'aws-cdk-lib/aws-pinpoint';

declare const userPool: cognito.UserPool;
declare const pinpointApp: pinpoint.CfnApp;
declare const pinpointRole: iam.Role;

new cognito.UserPoolClient(this, 'Client', {
  userPool,
  analytics: {
    // Your Pinpoint project
    application: pinpointApp,

    // Whether to include user data in analytics events
    shareUserData: true,
  },
});
```

Python:

```python
import aws_cdk.aws_pinpoint as pinpoint

# user_pool: cognito.UserPool
# pinpoint_app: pinpoint.CfnApp
# pinpoint_role: iam.Role

cognito.UserPoolClient(self, "Client",
    user_pool=user_pool,
    analytics=cognito.AnalyticsConfiguration(
        # Your Pinpoint project
        application=pinpoint_app,

        # Whether to include user data in analytics events
        share_user_data=True
    )
)
```

Java:

```java
import software.amazon.awscdk.services.pinpoint.*;

UserPool userPool;
CfnApp pinpointApp;
Role pinpointRole;

UserPoolClient.Builder.create(this, "Client")
        .userPool(userPool)
        .analytics(AnalyticsConfiguration.builder()
                // Your Pinpoint project
                .application(pinpointApp)

                // Whether to include user data in analytics events
                .shareUserData(true)
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.Pinpoint;

UserPool userPool;
CfnApp pinpointApp;
Role pinpointRole;

new UserPoolClient(this, "Client", new UserPoolClientProps {
    UserPool = userPool,
    Analytics = new AnalyticsConfiguration {
        // Your Pinpoint project
        Application = pinpointApp,

        // Whether to include user data in analytics events
        ShareUserData = true
    }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import pinpoint "github.com/aws/aws-cdk-go/awscdk"

var userPool UserPool
var pinpointApp CfnApp
var pinpointRole Role

cognito.NewUserPoolClient(this, jsii.String("Client"), &UserPoolClientProps{
	UserPool: UserPool,
	Analytics: &AnalyticsConfiguration{
		// Your Pinpoint project
		Application: pinpointApp,

		// Whether to include user data in analytics events
		ShareUserData: jsii.Boolean(true),
	},
})
```

## Properties

- `application`: [CfnApp](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_pinpoint.CfnApp.html) — The Amazon Pinpoint project that you want to connect to your user pool app client.

  **Default:** no configuration, you need to specify either `application` or all of `applicationId`, `externalId`, and `role`.

  Amazon Cognito publishes events to the Amazon Pinpoint project.
  You can also configure your application to pass an endpoint ID in the `AnalyticsMetadata` parameter of sign-in operations.
  The endpoint ID is information about the destination for push notifications.

- `applicationId`: string — Your Amazon Pinpoint project ID.

  **Default:** no configuration, you need to specify either this property along with `externalId` and `role` or `application`.

- `externalId`: string — The external ID of the role that Amazon Cognito assumes to send analytics data to Amazon Pinpoint.

  **Default:** no configuration, you need to specify either this property along with `applicationId` and `role` or `application`.

  More info here: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html

- `role`: [IRoleRef](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_iam.IRoleRef.html) — The IAM role that has the permissions required for Amazon Cognito to publish events to Amazon Pinpoint analytics.

  **Default:** no configuration, you need to specify either this property along with `applicationId` and `externalId` or `application`.

- `shareUserData`: boolean = false — If `true`, Amazon Cognito includes user data in the events that it publishes to Amazon Pinpoint analytics.
