APIs & Integrations

CScognamiglio
Member

Identify a visitor

SOLVE

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
0 Upvotes
1 Accepted solution
CScognamiglio
Solution
Member

Identify a visitor

SOLVE

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 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"></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>

View solution in original post

3 Replies 3
Oezcan
Top Contributor | Diamond Partner
Top Contributor | Diamond Partner

Identify a visitor

SOLVE

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

 

Thanks for mentioning Dennis, made me curious about the topic. 🙂

I hope you help @CScognamiglio ,

Best regards,

Özcan

Oezcan Eser Signature
CScognamiglio
Solution
Member

Identify a visitor

SOLVE

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 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"></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>

dennisedson
HubSpot Product Team
HubSpot Product Team

Identify a visitor

SOLVE

@Oezcan , any chance you can assist here?

0 Upvotes