Issue
When initializing the Intercom SDK via analytics.js, you encounter the following authentication error message from the Intercom widget:
Missing user_hash or intercom_user_jwt. A valid user_hash or intercom_user_jwt is required to authenticate users when Messenger Security is enforced
Product
Segment
Cause
This error occurs when Intercom Messenger Security is turned on or enforced within your Intercom workspace settings. When this security setting is active, Intercom mandates that a signed JSON Web Token (JWT) or a user hash accompany client-side initialization to verify the user's identity. If your analytics.js implementation does not explicitly pass this token during setup or identity calls, the Intercom messenger widget will block authentication and throw this error.
Resolution
To resolve this issue, you must supply the signed JWT inside the integrations options parameter of your analytics.identify() call.
Follow these steps to update your implementation:
Configure your backend server to generate a secure, signed JWT for the authenticated user according to Intercom's specification guidelines.
Update your client-side tracking code to pass this token directly into the
Intercomdestination object within youranalytics.identifycall using eitherintercom_user_jwtorintercomUserJwt:
analytics.identify('user-id', {
email: 'user@example.com'
}, {
integrations: {
Intercom: {
intercom_user_jwt: 'YOUR_JWT_TOKEN_HERE'
}
}
});-
Leveraging the Intercom Web Mode (Actions) destination, ensure that your Identify User action mapping is configured to map this incoming custom integration option.
This is configured on the
Identify Usermapping that is created with the destination
Note: If you need to perform additional post-load tasks or manipulate the widget directly, you can wrap your logic using the
analytics.ready()callback method, which ensures the Intercom instance has fully booted.
Note: A user hash can be passed in the same manner as the user JWT by replacing
intercom_user_jwtwith eitheruser_hashoruserHash.