VID as contact identifier in Javascript API


#1

I’m running into an issue with the way the api is structured and the way Hubspot is essentially using 2 primary reference keys for contacts (vid/email).

I am integrating a Rails app with Hubspot and am offloading the API calls to workers so they are non blocking and won’t slow the app down.
I am using the HTTP api calls to get the benefit of the response body and then saving the vid in my apps user table so I can associate this with later api calls for the given user.
I am also using the JS API for user event tracking on the app.

When I update a user email on our system the app sends the background worker to call to update our contact on hubspot. On page redirect the js on the page grabs the updated user email and creates a new user on hubspot before the worker can update the same users email via the background worker api call. So, I’m left with same user with 2 contacts on hubspot, since the JS api creates a new user based on the new email.

I know it is possible to merge two users after the fact via the api, but it seems like using the email as the primary key in the js code is a bit fragile, when emails are something that can and will change for a user on any given application.

Is there any way to use the unique vid as the identifier in the JS api? If not, should this not at least be an option?


#2

Hi @grant

The contact vid is not something that can currently be used with the Events API, but I’ll bring it up with our Analytics team and see if it’s something we can add. The Events APIs were designed around working with data that would be present on a site (i.e. someone puts their email address into a form field) or in a system that wasn’t necessarily connected to HubSpot, and with email being unique in HubSpot, it’s usually a good way to identify a record (unless you have a lot of users that update their email address).

For users that do change their email, have they previously been identified by email using the JavaScript API? Or have they previously filled out a form? Any call to the Events API also identifies the user by their hubspotutk cookie (usually called the usertoken), so as long as the usertoken has been associated with a HubSpot contact (either through the JavaScript Events API or a form submission that includes the token), you wouldn’t need to identify the visitor again, since the event would still be tied to the contact by the usertoken.


#3

@dadams I am running into this exact same issue. What if someone is visiting our app/site from another browser or different session where they don’t have an identified hubspotutk? We still want to track their page tracking activity. Right now, the only solution would seem to be merging contacts, which isn’t always ideal.

We were identifying people by their email address. The problem is when they update their email address within the app, it creates a new user on the next page after they save their settings. Since like @grant we use workers in a queue, we cannot guarantee when the update to Hubspot will happen, so its not like we can update server side, and then identify them in JS on the next page with the new email address.

What the real solution here is, identify should work with vid, just like it does with email on every other API call. http://developers.hubspot.com/docs/methods/tracking_code_api/identify_visitor

var _hsq = window._hsq = window._hsq || [];
_hsq.push([“identify”,{
vid: 8282828
}]);


#4

Was this functionality ever added to the JavaScript events API?