APIs & Integrations

TRaymondRoto
Contributor

Hubspot Chatbot Code Snippet to set Contact Properties

I'm looking to set some contact properties from values found on the web page that Hubspot Chat is embedded on.   For example, I have the UTM parameters the user came to the site with stored in local storage.  When the user starts a chat session, I'd like to take those UTM variables (from Local Storage) and set a series of Contact Properties with those values (all unseen to the end user).

I can't seem to find any examples of this (which seems like a fairly common use case).  Can anyone point me in the right direction (or better yet, post an example of this in action)?

0 Upvotes
2 Replies 2
HMir
Member

Hubspot Chatbot Code Snippet to set Contact Properties


@TRaymondRoto wrote:

I'm looking to set some contact properties from values found on the web page that Hubspot Chat is embedded on.   For example, I have the UTM parameters the user came to the site with stored in local storage.  When the user starts a chat session, I'd like to take those UTM variables (from Local Storage) and set a series of Contact Properties with those values (all unseen to the end user).

I can't seem to find any examples of this (which seems like a fairly common use case).  Can anyone point me in the right direction (or better yet, post an example of this in action)?


To set HubSpot contact properties from UTM parameters stored in local storage, you can use HubSpot's JavaScript API. First, retrieve the UTM parameters from local storage, then use the hbspt.forms.create function or HubSpot's chat widget API to set these values as contact properties when a user starts a chat. This allows you to capture UTM information (like source, medium, campaign, etc.) without the user seeing it. Here's an example of how you can integrate the UTM parameters with HubSpot's chat system to automatically update the contact properties.

0 Upvotes
TRaymondRoto
Contributor

Hubspot Chatbot Code Snippet to set Contact Properties

Sorry....Did you forget to attach or hyperlink the example?

0 Upvotes