<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to display total of all instances of a contact field in Blog, Website &amp; Page Publishing</title>
    <link>https://community.hubspot.com/t5/Blog-Website-Page-Publishing/How-to-display-total-of-all-instances-of-a-contact-field/m-p/1088644#M14344</link>
    <description>&lt;P&gt;Hi &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/836573"&gt;@studeomedia&lt;/a&gt;&lt;/SPAN&gt; and welcome, we are so glad to have you here!&lt;BR /&gt;Also, I'd like to wish you a very Happy New Year! &lt;span class="lia-unicode-emoji" title=":party_popper:"&gt;🎉&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you for asking the HubSpot Community!&lt;BR /&gt;&lt;BR /&gt;I'd love to put you in touch with some of our Top Experts: Hi &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/166093"&gt;@miljkovicmisa&lt;/a&gt;&lt;/SPAN&gt;, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/114957"&gt;@Syeda_Fatima&lt;/a&gt;&lt;/SPAN&gt;, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/133"&gt;@stefen&lt;/a&gt;&lt;/SPAN&gt; and &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/91608"&gt;@alyssamwilie&lt;/a&gt;&lt;/SPAN&gt; do you have suggestions to help &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/836573"&gt;@studeomedia&lt;/a&gt;&lt;/SPAN&gt;, please?&lt;BR /&gt;&lt;BR /&gt;Have a fantastic day and thanks so much! &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Bérangère&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jan 2025 08:38:05 GMT</pubDate>
    <dc:creator>BérangèreL</dc:creator>
    <dc:date>2025-01-02T08:38:05Z</dc:date>
    <item>
      <title>How to display total of all instances of a contact field</title>
      <link>https://community.hubspot.com/t5/Blog-Website-Page-Publishing/How-to-display-total-of-all-instances-of-a-contact-field/m-p/1088515#M14338</link>
      <description>&lt;P&gt;Suppose I am building a crowdfunding site in CMS. I've added a custom contact field for the amount of money a user would contribute to the investment offering when it is launched. I then want to display the total number of unique users supporting the project and the total dollar amount pledged on a CMS web page. What is the best way to accomplish this? Workflow or JavaScript which calls the Contacts API?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Jan 2025 16:11:04 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Blog-Website-Page-Publishing/How-to-display-total-of-all-instances-of-a-contact-field/m-p/1088515#M14338</guid>
      <dc:creator>studeomedia</dc:creator>
      <dc:date>2025-01-01T16:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to display total of all instances of a contact field</title>
      <link>https://community.hubspot.com/t5/Blog-Website-Page-Publishing/How-to-display-total-of-all-instances-of-a-contact-field/m-p/1088644#M14344</link>
      <description>&lt;P&gt;Hi &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/836573"&gt;@studeomedia&lt;/a&gt;&lt;/SPAN&gt; and welcome, we are so glad to have you here!&lt;BR /&gt;Also, I'd like to wish you a very Happy New Year! &lt;span class="lia-unicode-emoji" title=":party_popper:"&gt;🎉&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you for asking the HubSpot Community!&lt;BR /&gt;&lt;BR /&gt;I'd love to put you in touch with some of our Top Experts: Hi &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/166093"&gt;@miljkovicmisa&lt;/a&gt;&lt;/SPAN&gt;, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/114957"&gt;@Syeda_Fatima&lt;/a&gt;&lt;/SPAN&gt;, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/133"&gt;@stefen&lt;/a&gt;&lt;/SPAN&gt; and &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/91608"&gt;@alyssamwilie&lt;/a&gt;&lt;/SPAN&gt; do you have suggestions to help &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/836573"&gt;@studeomedia&lt;/a&gt;&lt;/SPAN&gt;, please?&lt;BR /&gt;&lt;BR /&gt;Have a fantastic day and thanks so much! &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Bérangère&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2025 08:38:05 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Blog-Website-Page-Publishing/How-to-display-total-of-all-instances-of-a-contact-field/m-p/1088644#M14344</guid>
      <dc:creator>BérangèreL</dc:creator>
      <dc:date>2025-01-02T08:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to display total of all instances of a contact field</title>
      <link>https://community.hubspot.com/t5/Blog-Website-Page-Publishing/How-to-display-total-of-all-instances-of-a-contact-field/m-p/1099268#M14577</link>
      <description>&lt;P&gt;Raising this to the top again. Any suggestions would be appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 18:18:20 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Blog-Website-Page-Publishing/How-to-display-total-of-all-instances-of-a-contact-field/m-p/1099268#M14577</guid>
      <dc:creator>studeomedia</dc:creator>
      <dc:date>2025-01-24T18:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to display total of all instances of a contact field</title>
      <link>https://community.hubspot.com/t5/Blog-Website-Page-Publishing/How-to-display-total-of-all-instances-of-a-contact-field/m-p/1109311#M14760</link>
      <description>&lt;P&gt;Hi &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/836573"&gt;@studeomedia&lt;/a&gt;&lt;/SPAN&gt; and thanks for raising this up!&lt;BR /&gt;&lt;BR /&gt;Hey &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/363300"&gt;@Jnix284&lt;/a&gt;&lt;/SPAN&gt;, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/123775"&gt;@danmoyle&lt;/a&gt;&lt;/SPAN&gt; and &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/601366"&gt;@sylvain_tirreau&lt;/a&gt;&lt;/SPAN&gt;, I know that you have lots of great experiences using HubSpot so I was wondering if you have suggestions to help &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/836573"&gt;@studeomedia&lt;/a&gt;&lt;/SPAN&gt; report on the total number of unique users supporting the project and the total dollar amount pledged on a CMS web page, please?&lt;BR /&gt;&lt;BR /&gt;Have a lovely weekend and thanks so much in advance for sharing your amazing expertise with the Community! &lt;span class="lia-unicode-emoji" title=":red_heart:"&gt;❤️&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Bérangère&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2025 16:23:59 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Blog-Website-Page-Publishing/How-to-display-total-of-all-instances-of-a-contact-field/m-p/1109311#M14760</guid>
      <dc:creator>BérangèreL</dc:creator>
      <dc:date>2025-02-14T16:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to display total of all instances of a contact field</title>
      <link>https://community.hubspot.com/t5/Blog-Website-Page-Publishing/How-to-display-total-of-all-instances-of-a-contact-field/m-p/1109406#M14764</link>
      <description>&lt;P&gt;Hey there&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/836573"&gt;@studeomedia&lt;/a&gt;&amp;nbsp;and welcome to the Community. I think this is something you could maybe do using javascript to call the Contacts API - seems it would be more flexible and work in a more real-time situation. I found this example code - but please know I'm not a developer, just a long-time HubSpot user.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;const hubspot = require('@hubspot/api-client');
const hubspotClient = new hubspot.Client({ accessToken: 'YOUR_ACCESS_TOKEN' });

async function getCrowdfundingStats() {
  try {
    let after = undefined;
    let totalUsers = 0;
    let totalPledged = 0;

    do {
      const apiResponse = await hubspotClient.crm.contacts.basicApi.getPage(
        100,
        after,
        ['pledge_amount'],
        undefined,
        undefined,
        false
      );

      totalUsers += apiResponse.results.length;
      totalPledged += apiResponse.results.reduce((sum, contact) =&amp;gt; 
        sum + (parseFloat(contact.properties.pledge_amount) || 0), 0);

      after = apiResponse.paging?.next?.after;
    } while (after);

    return { totalUsers, totalPledged };
  } catch (e) {
    console.error('Error fetching crowdfunding stats:', e);
  }
}

// Call this function and update your HubSpot page with the results
getCrowdfundingStats().then(stats =&amp;gt; {
  document.getElementById('totalUsers').textContent = stats.totalUsers;
  document.getElementById('totalPledged').textContent = stats.totalPledged.toFixed(2);
});
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should be able to create a custom module in HubSpot CMS and add the JavaScript code to the module, ensuring you replace 'YOUR_ACCESS_TOKEN' with your actual HubSpot API access token.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, create HTML elements in your module to display the results (e.g., with IDs 'totalUsers' and 'totalPledged'). Finally, you would add the custom module to your crowdfunding project page.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You probably also want to make sure you handle API rate limits and implement error handling for a production-ready solution, and consider caching the results for a short period to improve performance for high-traffic pages. Hopefully this helps!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2025 19:26:57 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/Blog-Website-Page-Publishing/How-to-display-total-of-all-instances-of-a-contact-field/m-p/1109406#M14764</guid>
      <dc:creator>danmoyle</dc:creator>
      <dc:date>2025-02-14T19:26:57Z</dc:date>
    </item>
  </channel>
</rss>

