APIs & Integrations

Joe_Dix
Member

How to publish list count on site frontend

SOLVE

We're trying to develop a petition-style tool using HubSpot.

 

When a user fills in the form to sign the petition they will be added to a list. I want to be able to show how many people have signed the petition already (to encourage others to take part), but can't figure out if there is a way in hubl to extract the number of entries in a specific list.

 

I've seen someone has done it using javascript to call the API but this would make the API key available so I don't want to do that.

0 Upvotes
1 Accepted solution
cbarley
Solution
HubSpot Alumni
HubSpot Alumni

How to publish list count on site frontend

SOLVE

Hi @Joe_Dix , you can't call the HubSpot Lists API on the frontend : https://developers.hubspot.com/docs/faq/do-hubspot-apis-support-ajax-request. You'd need to make this query server-side and pass that information to the frontend. 

View solution in original post

0 Upvotes
3 Replies 3
cbarley
Solution
HubSpot Alumni
HubSpot Alumni

How to publish list count on site frontend

SOLVE

Hi @Joe_Dix , you can't call the HubSpot Lists API on the frontend : https://developers.hubspot.com/docs/faq/do-hubspot-apis-support-ajax-request. You'd need to make this query server-side and pass that information to the frontend. 

0 Upvotes
mgoswick
Contributor

How to publish list count on site frontend

SOLVE

Is there any way to just display the information using HubL instead? So rather that using an AJAX implementation, the HubL code would handle getting the data server-side and just display it as a HubL token?

0 Upvotes
cbarley
HubSpot Alumni
HubSpot Alumni

How to publish list count on site frontend

SOLVE

Hi @mgoswick , there's no way to show all folks that are in a list, but you can use tokens like request.contact.list_memberships to see if a visitor is in a specific list with a certain ID, then do something for that visitor if you'd like. We also do have this crm_object function as well that can display contact data but it may not be as robust as you'd need: https://designers.hubspot.com/en/docs/hubl/hubl-supported-functions#crm-object