Identify method not updating non email contact properties


#1

I am attempting to update contact properties using _hsq.push(["identify"]) as documented but I am finding that it will only create contacts and add email, other properties are ignored.

as a test I am running code like this

_hsq.push(["identify",{
email: "testman123456hubspot@yahoo.com",
firstname: 'orange'
}]);

and then to push it to hubspot

_hsq.push(["trackEvent", {
    id: "User Identified"
}])

The contact is created with my email, but firstname and any other property, custom or not is ignored. Any clue what Im doing wrong here?


#3

Welcome, @peterlazzarino.

I successfully created this contact:

with the following script embedded directly on one of my web pages:

<script>
var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
    email: 'identify_test_email_1@hubspot.com',
    firstname: 'Identify Test Email 1',
    lastname: 'From Page 2'
}]);
_hsq.push(['trackPageView']);
</script>

In your test code, you've placed the email value within double quotes while the firstname property value is in single quotes. I wonder, if you only use single quotes, does it make a difference?

Also, would you mind trying to place var _hsq = window._hsq = window._hsq || []; just before the identify method?


#5

I've just modified my code based on the example you've provided with no luck. I am sending firstname and lastname and neither get updated. Also in your example there was no trackEvent, but contacts won't update on my end without sending a trackEvent. Is there anything specific to my account or setup that could be happening here?

    var _hsq = window._hsq = window._hsq || []
    _hsq.push(['identify', {
        email: email,
        firstname: 'Test FN',
        lastname: 'Test LN'
    }]);
    _hsq.push(['trackPageView'])
    _hsq.push(['trackEvent', {
        id: "User Identified"
    }])

Attaching an image of the user, I did also check in all properties to verify the ones I am sending are blank.

19%20AM


#6

Hey, @peterlazzarino.

Strange. A very slight modification of that code worked for me:

<script>
 var _hsq = window._hsq = window._hsq || []
    _hsq.push(['identify', {
        email: 'identify_test_email_3@hubspot.com',
        firstname: 'Test FN 1',
        lastname: 'Test LN 2'
    }]);
    _hsq.push(['trackPageView'])
</script>

Could you share a link to a page with this code on it that I could test? Additionally, could you send me a link to that contact record (or a similar one showing the issue)?

Finally, are you saying that trackPageView on its own doesn't create the contact for you? Per the identify function's documentation, either the trackPageView or trackEvent should work — you don't need to use both.


#7

Hey Isaac,

Thanks for the help so far. It seems your code is essentially the same as mine except for the email variable which is dynamic in my case.

I just created a contact using the code I provided above and its located here https://app.hubspot.com/contacts/2416790/contact/163846001/?interaction=note

my hubspot username is peter@collegevine.com

The url where this is active is https://my.collegevine.com/start, you can go through the wizard with dummy data if you'd like for testing purposes. The event is sent to hubspot after Step 7 / email address entry when next is hit.


#8

Also Isaac, just realized that our production code does not include first and lastname fields. I have been testing by dropping your examples into the console until I can get this working. You should be able to do the same on that step or even the first step since the hubspot tracking script is loaded on every page.


#9

Hey, @peterlazzarino.

Thanks for all that information.

I tried a few times to create contacts with firstname and lastname values through the console, but this record was only created upon completing step 7. The same code executed perfectly on my own site's console...

I'm not quite sure what's going on there, but I'd like to explore alternatives for a second. Is there a reason why you're attempting to use the identify function instead of the Forms API? On the surface, the Forms API seems like a much better fit for the kind of information you're gathering and trying to pass to HubSpot.

To be transparent, I'll be heading on vacation shortly, so I may miss your responses. While I'm out of office next week, my teammates @Derek_Gervais and @Connor_Barley will be keeping an eye on my ongoing threads.


#10

Hi Isaac,

I have been able to successfully create them through my console but only after triggering an event.

I have not really explored the forms API option. Does it require authentication with OAuth? I wanted to keep our hubspot dependency on these pages as lightweight as possible.


#11

Hey, @peterlazzarino.

Ah, gotcha.

Nope, the Forms API doesn't require any authentication. You can just gather the desired field values, format them into JSON, and shoot them to the endpoint. You will need to create a HubSpot "copy" of your Squarespace form with a unique formGuid to receive these submissions.


#12

Alright I'll give it a try, thanks!