⚠️ Note that this post hasn't been updated for at least a year and the information may be outdated, proceed with caution! (Last updated: October 14, 2022)
In HubSpot, you can create pages where users can view their own information when logged in. For example, the deals associated with their contact record.
Note that this functionality is available if you have access to Membership pages, available on CMS Enterprise.
Get a contact's data
To get a contact's data on your HubSpot CMS page, you can use the crm_object
or crm_objects
HubL functions. For security reasons, this can only be done on a password-protected or membership login page.
To get a contact's first and last name using the crm_object
function, you would write something like the following code, with the three parameters being the object type ('contact'
), the object ID (in this case retrieved from a logged-in member - request.contact.contact_vid
), and the object fields you'd like to retrieve ('firstname,lastname'
):
See the Pen [Blog Post Example] Find the deals associated with a contact on a HubSpot membership page 1 by Stephanie O'Gay Garcia (@stephanieogaygarcia) on CodePen.
Get a contact's associated deals
To get this contact's associated deals, you would use the crm_associations
HubL functions and write something like the following code, with the three parameters being the object ID (again, in this case, retrieved from a logged-in member- request.contact.contact_vid
), the object category ('HUBSPOT_DEFINED'
), the association type ID (in this case 4
, "Contact to deal") and the object fields you'd like to retrieve ('dealname,amount'
):
See the Pen [Blog Post Example] Find the deals associated with a contact on a HubSpot membership page 2 by Stephanie O'Gay Garcia (@stephanieogaygarcia) on CodePen.
The above two code snippets should render the following HTML when a user is logged in:
See the Pen [Blog Post Example] Find the deals associated with a contact on a HubSpot membership page 3 by Stephanie O'Gay Garcia (@stephanieogaygarcia) on CodePen.
You can retrieve any data from other object types (product
, marketing_event
, contact
, company
, deal
, ticket
, quote
or custom if you have an Enterprise account) and their associations by using variations on the code above with the relevant parameters.