Identify API


I'm executing the identify API when my "thank you" modal appears. 


This is my code:



try {
	var _hsq = window._hsq = window._hsq || [];
		"email": email 
	_hsq.push(['setPath', '/#/consultation-thankyou']);
	// Track the page view for the new page
} catch(err) {




If I submit with an email that already has a contact, it doesn't seem to do anything with the identity or the pagview.


If I submit with an email that has no contact, I see my "pageview" but it didn't seem to pick up any of my website activity history and instead of recording the pageview at the "thankyou" path is recorded it at my home page and said the user came from "thankyou".


Is this expected behavior? Is this because I've already have a contact associated with the  activity cookie?  When calling the form api, it seems to behave different, if i pass context.huk then it will update the existing contat and replace the email. 


Also, another odd thing I noticed is that when I use Zapier to fire the form submit and pass the user token, it also seems to ignore it.  


I'm not sure if these issues are related to me not understanding something about how the cookie/identify works. Or if there are seperate issues at play.

4 Replies 4
Community Manager

@himanshurauthan 👋

Any chance you could help out here?



Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
Recognized Expert | Platinum Partner

Thank you @dennisedson for counting me in.


Hello @douglas_volt,


Code seems to be fine, and from here you can get a better idea of how HubSpot tracks visitors -




Digital Marketing & Inbound Expert In Growth Hacking Technology

Thanks for that. The doc you shared aligned with my expectations as well, but something is definitely not working right.


I thought maybe it was because I'm doing a lot of testing and my cookie is getting used on multiple contacts, but when I use the API, it just merges the contacts into 1 record, or puts that new email on that existing contact. That's using the form API and passing the huk to the context.


When I call identify, it always creates a new contact and doesn't seem to tie tht contact to any prior activity. It certainly doesn't merge them together like the form API call does.


The zapier form submission zap just seems to be totally broken, because I pass the hubspotutk cookie to it just like I do with the API and it just doesn't seem to tie the actiiites to the new contact created with the form. 


But again, it could be order of operations, maybe when the contact already exists, or some conditions about how I'm testing is causing it to be have different. I'm considering just ditching the identify() and zapier, and just going with my own cloud functions with the direct API connect.

Recognized Expert | Platinum Partner

Hi @douglas_volt,


Yes, it might be the order of operations. But as I see you are executing this code on thank you modal load, and by that time the form submission is triggered.


The identity API, don't send any data to HubSpot, it's sending when you are executing the pageview API.


You might try on email enter the identify API and then on thankyou you might trigger the page view?



Digital Marketing & Inbound Expert In Growth Hacking Technology