---
schema_version: "1"
id: a46b6c2c9b552078d8611ae0e298c4fc19dc563f828001ef15e6321a187119e1
title: Custom Interactions
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform-pkg-exchange/managed_packaging/guides/second-generation/appexchange/app-analytics/app-analytics-read-logs/app-analytics-read-logs-custom-interactions.md
canonical_url: https://developer.salesforce.com/docs/platform/pkg2-dev/guide/app-analytics-read-logs-custom-interactions.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 8e764a9bfcd7de4e5ce6d925b6be09d8abeab60c7ee786ebf33747727e9ddb3c
products:
  - Second-Generation Managed Packaging Developer Guide
  - merged-docs
---

# Custom Interactions

To understand which features and UI components a subscriber interacted with and how they flow through a user journey, create custom interactions with Apex enums and the `IsvPartners.AppAnalytics.logCustomInteraction` Apex method.

| Required Editions                                                                        |
| ---------------------------------------------------------------------------------------- |
| Available in: both Salesforce Classic and Lightning Experience                           |
| Available in: **Enterprise**, **Performance**, **Unlimited**, and **Developer** Editions |

| Standard Data                                                                                           | Supplemental Data |
| ------------------------------------------------------------------------------------------------------- | ----------------- |
| <ul><li>`class_name`</li><li>`method_name`</li><li>line_number</li><li>`interaction_id_token`</li></ul> | `api_version`     |

## Successful Custom Interactions

To analyze a custom interaction with your packaged components, look for a `log_record_type` of `CustomInteraction` and a `custom_entity_type` of `CustomInteractionLabel`. The `custom_entity` contains a custom interaction label that you created and that was logged.

**note:** `interaction_id_token` is included only if an `interaction_id` was provided to the associated `IsvPartners.AppAnalytics.logCustomInteraction` call. `interaction_id_token` is a hashed, tokenized version of the raw interaction id that was provided.

## Unsuccessful Custom Interactions

When `custom_entity_type` is equal to CustomInteractionFailure then the custom interaction couldn’t be logged. To determine the reason for the failed logging, review the reason code provided by the `custom_entity` value.

| custom_entity           | Message                                                                                                                                                                                                            |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `LABEL_NO_NAMESPACE`    | We couldn’t log the custom interaction with App Analytics. The interaction label provided to `IsvPartners.AppAnalytics.logCustomInteraction` must have a namespace.                                                |
| `LABEL_NOT_ENUM`        | We couldn’t log the custom interaction with App Analytics. The interaction label provided to `IsvPartners.AppAnalytics.logCustomInteraction` must be an Apex enum.                                                 |
| `LABEL_WRONG_NAMESPACE` | We couldn’t log the custom interaction with App Analytics. The interaction label provided to `IsvPartners.AppAnalytics.logCustomInteraction` must have the same namespace as the Apex code that called the method. |
| `OVER_CALL_LIMIT`       | `IsvPartners.AppAnalytics.logCustomInteraction` was called too many times in a single user request. This custom interaction and subsequent ones for this user request weren’t logged with App Analytics.           |

## Example

Let’s look at an example package usage log record and analyze a successful Apex interaction.

```nolang
{
    "timestamp_derived": "2023-09-20T06:17:39.167Z",
    "log_record_type": "CustomInteraction",
    "request_id": "TID:7635077000004b3035",
    "organization_id": "00Dxx0000006H2l",
    "organization_name": "MyCustomer Inc.",
    "organization_status": "Demo",
    "organization_edition": "Enterprise Edition",
    "organization_country_code": "IN",
    "organization_language_locale": "en_US",
    "organization_time_zone": "Australia/Sydney",
    "organization_instance": "GS0",
    "organization_type": "Production",
    "user_id_token": "005-9BwnBWYO5FMn4cZ1sLw7F3LmTpoe8M77GrZOZHL6xQk=",
    "user_type": "Standard",
    "package_id": "033xx0000004FqD",
    "package_version_id": "04txx0000004Idi",
    "managed_package_namespace": "Acme",
    "custom_entity": "MyInteractionLabels.LoginButtonClicked",
    "custom_entity_type": "CustomInteractionLabel",
    "session_key": "2l4YtFB/RmsRKVsS",
    "login_key": "fGV6RgVOH3ZCgl2v",
    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/IP_ADDRESS_REMOVED Safari/537.36",
    "user_country_code": "US",
    "user_time_zone": "America/Los_Angeles",
    "class_name": "Acme.MyController",
    "method_name": "loginButtonCallback",
    "line_number": 56,
    "interaction_id_token": "7NDe8HM8ZgPdBL+jiOpTW3/xKTwwL30dyxmKNxtyzi8="
}

```

The `MyInteractionLabels.LoginButtonClicked` custom interaction label was logged as a custom interaction as a result of a user action from subscriber org MyCustomer Inc on 2023-09-20 at 6:17 am. Specifically, the user interaction resulted in logging a custom interaction from line number 56 of the `loginButtonCallback` method found in the `Acme.MyController` Apex class. In addition to the `InteractionLabels.LoginButtonClicked` label, an interaction ID was provided to the log call resulting in an interaction token id value of `7NDe8HM8ZgPdBL+jiOpTW3/xKTwwL30dyxmKNxtyzi8=`.

The key data in this analysis are:

| Question | Field                                                                                                                                                                                                                                                | Value                                                                                                                                                                                                                                                              |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| What     | <ul><li>`class_name`</li><li>`custom_entity`</li><li>`custom_entity_type`</li><li>`package_version_id`</li><li>`managed_package_namespace`</li><li>`class_name`</li><li>`method_name`</li><li>`line_number`</li><li>`interaction_id_token`</li></ul> | <ul><li>`Acme.MyController`</li><li>`MyInteractionLabels.LoginButtonClicked`</li><li>`CustomInteractionLabel`</li><li>`04txx0000004Idi`</li><li>`Acme`</li><li>`loginButtonCallback`</li><li>`56`</li><li>`7NDe8HM8ZgPdBL+jiOpTW3/xKTwwL30dyxmKNxtyzi8=`</li></ul> |
| Who      | <ul><li>`organization_id`</li><li>`user_id_token`</li></ul>                                                                                                                                                                                          | <ul><li>`00Dxx0000006H2l`</li><li>`005-9BwnBWYO5FMn4cZ1sLw7F3LmTpoe8M77GrZOZHL6xQk=`</li></ul>                                                                                                                                                                     |
| How      | `log_record_type`                                                                                                                                                                                                                                    | `CustomInteraction`                                                                                                                                                                                                                                                |
| When     | `timestamp_derived`                                                                                                                                                                                                                                  | `2023-09-20T06:17:39.167Z`                                                                                                                                                                                                                                         |

**See Also**

- [Download Package Usage Logs, Package Usage Summaries, and Subscriber Snapshots](https://developer.salesforce.com/docs/platform/pkg2-dev/app-analytics-download-mp-logs.md)
- [Considerations for Custom Interactions](https://developer.salesforce.com/docs/platform/pkg2-dev/app-analytics-custom-interactions.md)
