# Identify a visitor

**URL:** <https://community.hubspot.com/t/identify-a-visitor/51821>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [February 18, 2022, 12:52pm UTC](https://community.hubspot.com/t/identify-a-visitor/51821 "2022-02-18T12:52:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CScognamiglio](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@CScognamiglio](https://community.hubspot.com/u/CScognamiglio)\
**Post date:** [February 18, 2022, 12:52pm UTC](https://community.hubspot.com/t/identify-a-visitor/51821/1 "2022-02-18T12:52:55Z")

</div>

I’ve installed the hubspot tracking code in my React App however every time a new user fill a (not Hubspot form) to sign in the email of the user is directly associated to my (own) entry in the CRM which is updated with the new user email.

import { useTrackingCode } from “react-hubspot-tracking-code-hook”;

import { useGetOwnUser } from ‘./userHooks’

export const useHubSpotHook = ({ page }) =\> {

const { setPathPageView, setIdentity, setContentType } = useTrackingCode();

const { userData } = useGetOwnUser()

setPathPageView(page);

setIdentity(userData.email);

setContentType(“landing-page”);

};

is this dependant on the user accepting the cookie tracking from the hubspot consent box ?

Thanks for your help

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [February 22, 2022, 3:14pm UTC](https://community.hubspot.com/t/identify-a-visitor/51821/2 "2022-02-22T15:14:01Z")

</div>

@Oezcan , any chance you can assist here?

---

<div class="post-metadata">

**Author:** ![Oezcan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/oezcan/32/53959_2.png) [@Oezcan](https://community.hubspot.com/u/Oezcan)\
**Post date:** [February 23, 2022, 9:55am UTC](https://community.hubspot.com/t/identify-a-visitor/51821/3 "2022-02-23T09:55:03Z")

</div>

Hello @dennisedson , hello @CScognamiglio ,

Unfortunately I don’t know anything about it yet, but that’s what I found.

[https://legacydocs.hubspot.com/docs/methods/tracking\_code\_api/identify\_visitor](https://legacydocs.hubspot.com/docs/methods/tracking_code_api/identify_visitor)

Thanks for mentioning Dennis, made me curious about the topic. 🙂  
I hope you help @CScognamiglio ,

Best regards,

Özcan

---

<div class="post-metadata">

**Author:** ![CScognamiglio](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@CScognamiglio](https://community.hubspot.com/u/CScognamiglio)\
**Post date:** [February 23, 2022, 10:15am UTC](https://community.hubspot.com/t/identify-a-visitor/51821/4 "2022-02-23T10:15:10Z")

</div>

Thank you @Oezcan & @dennisedson

actually the code is correct. I’ve managed to make it work by updating the HS tracking code (which is installed on the React app via GTM) with the setPath and trackPageView as per below

The article here [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/api/events/tracking-code)  
for Tracking in single-page applications was very helpful

\<!-- Set up the path for the initial page view --\>  
\<script\>  
var \_hsq = window.\_hsq = window.\_hsq || [];  
\_hsq.push([‘setPath’, ‘/home’]);  
\</script\>

\<!-- Load the HubSpot tracking code --\>

\<!-- Start of HubSpot Embed Code --\>  
\<script type=“text/javascript” id=“hs-script-loader” async defer src=“[//js.hs-scripts.com/xxxxxxxx.js](https://js.hs-scripts.com/xxxxxxxx.js)”\>\</script\>  
\<!-- End of HubSpot Embed Code --\>

\<!-- Tracking subsequent page views --\>  
\<script\>  
var \_hsq = window.\_hsq = window.\_hsq || [];  
\_hsq.push([‘setPath’, ‘/about-us’]);  
\_hsq.push([‘trackPageView’]);  
\</script\>
