# Issue with identifying user in Rudderstack + Hubspot (React.js app)

**URL:** <https://community.hubspot.com/t/issue-with-identifying-user-in-rudderstack-hubspot-react-js-app/127564>\
**Category:** APIs & Integrations\
**Tags:** professional, starter\
**Created:** [March 7, 2025, 6:15pm UTC](https://community.hubspot.com/t/issue-with-identifying-user-in-rudderstack-hubspot-react-js-app/127564 "2025-03-07T18:15:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ARafalskyi](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@ARafalskyi](https://community.hubspot.com/u/ARafalskyi)\
**Post date:** [March 7, 2025, 6:15pm UTC](https://community.hubspot.com/t/issue-with-identifying-user-in-rudderstack-hubspot-react-js-app/127564/1 "2025-03-07T18:15:34Z")

</div>

I am integrating Hubspot live chat in React.js application. I faced issue that I cannot identify user with Rudderstack and receive “Unknown Visitor” instead of actual user data like email, name etc.

Here is integration code:

```auto
import { useEffect } from 'react';

export const useHubspot = () => {
 useEffect(() => {
 const script = document.createElement('script');
 script.src = '//js-na1.hs-scripts.com/id.js';
 script.async = true;
 script.defer = true;
 script.id = 'hs-script-loader';
 document.body.appendChild(script);

 return () => {
 document.body.removeChild(script);
 };
 }, []);
};

```

This hook is run in parent App.ts

In LoginForm.tsx after successful login:

```auto
const dataToTrack = {
 userName: name,
 email,
 company: {
 id: client_data.client__id,
 name: client_data.client__name,
 },
};
rudderanalytics.identify(String(id), data);

```

In Rudderstack I set “email” field from traits as lookup field, set correct Private Apps token. I definitely see identify event in Rudderstack and see that all POST requests related to contacts in Hubspot resolved successfully.

After sending message from app’s live chat I receive message from “Unknown Visitor”. Any ideas why?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [March 10, 2025, 2:34pm UTC](https://community.hubspot.com/t/issue-with-identifying-user-in-rudderstack-hubspot-react-js-app/127564/2 "2025-03-10T14:34:07Z")

</div>

Hi, @ARafalskyi 👋 Welcome to our community. Thank you for including your details. I’d like to invite some of our community members to the conversation — hey @Anton @evaldas @GiantFocal, do you have any recent experience here? Or any general troubleshooting steps you like to take in situations like this. Thank you very much for taking a look! — Jaycee

---

<div class="post-metadata">

**Author:** ![GiantFocal](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/giantfocal/32/41969_2.png) [@GiantFocal](https://community.hubspot.com/u/GiantFocal)\
**Post date:** [March 11, 2025, 2:21am UTC](https://community.hubspot.com/t/issue-with-identifying-user-in-rudderstack-hubspot-react-js-app/127564/3 "2025-03-11T02:21:16Z")

</div>

Hi @ARafalskyi,

There might be several reasons:

1. Timing issues: The identify call happens after the Hubspot chat is already initialized
2. Incorrect data format: The way traits are being passed could be problematic
3. Missing connection between Rudderstack identity and Hubspot chat

You can try the following:

1. Follow the recommended format:

```lia-code-sample
rudderanalytics.identify(String(id), {
 name: name, // Pass name directly as a trait
 email: email, // Pass email directly as a trait
 company: {
 id: client_data.client__id,
 name: client_data.client__name
 }
});

```

2. Finally, make sure to identify the call happens **before** the chat interaction.
