APIs & Integrations

DimitrisV
Participant

Send a custom property to HubSpot via Tracking Code API

SOLVE

Hi,

 

We're trying to send a custom id to HubSpot for all the users that are visiting the website. Our aim is to have this Id available wherever a contact is created. Unfortunately, many contacts are created via the "Meetings" module thus we're not able to use a hidden field to send this id and ideally we would not like to change the flow. 

 

Currently, using the information from the documentation we're sending this Id in every pageview with the below snippet:

 

_hsq.push(["identify",{
     internal_id: {User's Internal Id}
 }]);
_hsq.push(['trackPageView']);

The above should work similarly with the attribution information, as the property should be set as soon as the visitor will reach out and the contact is created.

 

While this seem to be working for a couple users (even retrospectively - the id is set for users that are already a contact and re-visit the website), there are many (almost all) new contacts that they do not have this custom property set, even though they visited the website. Through our internal tests (visit the website as a new user, browse some pages, book a meeting) we always get this id. 

 

Do we have to do anything further to ensure this Id will be available for any contact? If not, is there another way?


Thank you in advance

0 Upvotes
1 Accepted solution
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Send a custom property to HubSpot via Tracking Code API

SOLVE

Hey @DimitrisV,

 

Thanks for clarifying!

 

Just to recap, you'd like to pass in internal ID and other properties using the identify a visitor function to store visitor information first. Subsequently, if the visitors submit a form/when the email is available, you'd like to populate the stored visitor information, am I understanding it correctly? 

 

If so, you'd likely need to follow a flow like this:

 

1. Store the visitor information:

var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
    id: "thisisatestid",
firstname: "mon211"
}]);
_hsq.push(['trackPageView']);

2. Once you have the visitor's email, you would need to repeat the steps again:

var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
    email: "monemail@hubspot.com"
}]);
_hsq.push(['trackPageView']);

 

When a contact is created with the email monemail@hubspot.com, the firstname will also be populated as mon211.

View solution in original post

4 Replies 4
WendyGoh
HubSpot Employee
HubSpot Employee

Send a custom property to HubSpot via Tracking Code API

SOLVE

Hey @DimitrisV,

 

I believe the key issue here is that your team is currently not passing in the email address.

 

As stated on this documentation,

 

 

However, unlike with an email address, including an 'id' by itself will not create a contact. Also, this 'id' is treated as a completely external identity, so while analytics data can be associated with a specific contact record by the ID (if, for example, you've previously identified a record by ID and by email, or the record was previously identified by ID and the visitor also has a form submission), the contact record cannot be looked up by this ID.

With the above in mind, I'd recommend your team to include the email field when identifying a visitor so that we can ensure all new contacts will be created within HubSpot.

0 Upvotes
DimitrisV
Participant

Send a custom property to HubSpot via Tracking Code API

SOLVE

Thank you for your reply @WendyGoh 

 

As mentioned, during the visit of the user, their e-mail is not available yet. This is why we try to attach this internal id to their cookie, and as soon as the contact is created at a later time, attribution information (e.g. original source) and our internal id should be available.

 

I am trying to understand how HubSpot is able to have a visitor's attribution information of their first visit prior to the user giving their e-mail and as soon as the contact is created attach the information. We try to mimic this approach because we're not able to use a hidden field to send the internal id as the "Book a Meeting" module is not supporting hidden fields.

 

 

0 Upvotes
WendyGoh
Solution
HubSpot Employee
HubSpot Employee

Send a custom property to HubSpot via Tracking Code API

SOLVE

Hey @DimitrisV,

 

Thanks for clarifying!

 

Just to recap, you'd like to pass in internal ID and other properties using the identify a visitor function to store visitor information first. Subsequently, if the visitors submit a form/when the email is available, you'd like to populate the stored visitor information, am I understanding it correctly? 

 

If so, you'd likely need to follow a flow like this:

 

1. Store the visitor information:

var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
    id: "thisisatestid",
firstname: "mon211"
}]);
_hsq.push(['trackPageView']);

2. Once you have the visitor's email, you would need to repeat the steps again:

var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
    email: "monemail@hubspot.com"
}]);
_hsq.push(['trackPageView']);

 

When a contact is created with the email monemail@hubspot.com, the firstname will also be populated as mon211.

DimitrisV
Participant

Send a custom property to HubSpot via Tracking Code API

SOLVE

Thank you @WendyGoh,

 

Indeed what you propose should work flawlessly. In the meantime, we found another way of having visitor information sent to HubSpot without providing the e-mail at all.

 

As you described, we noticed that if we use the "identify" function after the contact is created, then the information is stored appropriately. Thus, through Google Tag Manager, we're firing the snippet on every form submission and meeting booked. This ensures that the information is sent and it's attached to the contact 99% of the cases.

 

Again, thanks a lot for your help on this!