Contact creation via the Events Javascript API



The javascript API documentation says the “identify” method will create a new contact if one doesn’t already exist.
However, when I call it from our application, no contact gets created. I’ve verified that the analytics tracking code is loaded and the _hsq queue exists. I’m calling the identify method as follows:

_hsq.push(["identify", {
    email: "",
    firstname: "MyFirstName",
    lastname: "MyLastname"

Is there anything I’m missing to get this working?


I’m also having a similar issue. Did you have any luck getting this working @emile?


Hi @emile,

I suspect that there is an issue with the order in which items are added to the _hsq array here. As mentioned within the docs for the Events JS API ::

Note: Identities should be pushed as soon as possible, to make sure that the identities are pushed to HubSpot, since identities will only be passed to HubSpot with an event or when the tracking code loads on the page. Simply calling the identify method will not push the identities to HubSpot.

One of two things needs to happen here; either a) the user identity element is pushed to the _hsq array before the HS tracking code is loaded, or a HS event has to fire after the identity is pushed to the array. Please try either of these and let me know how you go.


I never managed to get this working and ended up using the Contacts API instead.

I can’t remember if I fired an event after the identity was pushed as @kfischmann suggests below. Have you tried that?


Thanks for the help. I’ll try out the approach @kfischmann suggested and see how I go.


This is working for me now. I think it was related to my previous issue where the “Clicked Element” tracking events with jquery selectors weren’t firing on a single page app. It’s working after switching to use the “trackEvent” method instead.