<?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 Creating custom behavioural event for button click in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1049809#M77098</link>
    <description>&lt;P&gt;Hello!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am trying to create a CBE for a button on our prefernces page. Essentially the CBE is created for the "Resubscribe" button.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The issue I am facing is my CBE not being able to store the button click. When the button is clicked it loads up a thank you page not giving enough time for the _hsq.push method to push the data onto HS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have so far for the CBE:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  const resubPrefBtn = document.getElementById('globalresub2');

  if (resubPrefBtn) {
    resubPrefBtn.addEventListener('click', () =&amp;gt; {
      console.log('clicked...');
      _hsq.push([
        'trackCustomBehavioralEvent',
        {
          name: 'pe20052921_resubscribe_email_preferences_button_click',
          properties: {
            // give each property a value so we know what they mean
          },
        },
      ]);
    });
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;What can I do to ensure that the execution of the CBE happens before the thank you page is shown?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Oct 2024 16:43:57 GMT</pubDate>
    <dc:creator>Mrafey</dc:creator>
    <dc:date>2024-10-03T16:43:57Z</dc:date>
    <item>
      <title>Creating custom behavioural event for button click</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1049809#M77098</link>
      <description>&lt;P&gt;Hello!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am trying to create a CBE for a button on our prefernces page. Essentially the CBE is created for the "Resubscribe" button.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The issue I am facing is my CBE not being able to store the button click. When the button is clicked it loads up a thank you page not giving enough time for the _hsq.push method to push the data onto HS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have so far for the CBE:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  const resubPrefBtn = document.getElementById('globalresub2');

  if (resubPrefBtn) {
    resubPrefBtn.addEventListener('click', () =&amp;gt; {
      console.log('clicked...');
      _hsq.push([
        'trackCustomBehavioralEvent',
        {
          name: 'pe20052921_resubscribe_email_preferences_button_click',
          properties: {
            // give each property a value so we know what they mean
          },
        },
      ]);
    });
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;What can I do to ensure that the execution of the CBE happens before the thank you page is shown?&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 16:43:57 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1049809#M77098</guid>
      <dc:creator>Mrafey</dc:creator>
      <dc:date>2024-10-03T16:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom behavioural event for button click</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1049833#M77099</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/505816"&gt;@Mrafey&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would need to use the preventDefault to "block"&amp;nbsp; the event from completing, then continue it after the hsq push.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;See the &lt;A href="https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault" target="_blank" rel="noopener"&gt;preventDefault MDN&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 17:11:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1049833#M77099</guid>
      <dc:creator>MrJustinGivens</dc:creator>
      <dc:date>2024-10-03T17:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom behavioural event for button click</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1049871#M77100</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/16592"&gt;@MrJustinGivens&lt;/a&gt;&amp;nbsp;!&lt;BR /&gt;&lt;BR /&gt;How can I continue after the hsq push function is executed?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 18:07:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1049871#M77100</guid>
      <dc:creator>Mrafey</dc:creator>
      <dc:date>2024-10-03T18:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom behavioural event for button click</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1049950#M77104</link>
      <description>&lt;P&gt;Depend on the button.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the button has an href attribute then gr&lt;SPAN&gt;ab the event.target.href and then use window.location = event.target.href;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 21:06:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1049950#M77104</guid>
      <dc:creator>MrJustinGivens</dc:creator>
      <dc:date>2024-10-03T21:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom behavioural event for button click</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1049954#M77105</link>
      <description>&lt;P&gt;Unfortunetly it does not have an href attribute. It actually is a input type of "submit"&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2024-10-03 at 5.13.02 PM.png" style="width: 553px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/128499iAA0E7E7EBD973B19/image-dimensions/553x39?v=v2" width="553" height="39" role="button" title="Screen Shot 2024-10-03 at 5.13.02 PM.png" alt="Screen Shot 2024-10-03 at 5.13.02 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 21:13:28 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1049954#M77105</guid>
      <dc:creator>Mrafey</dc:creator>
      <dc:date>2024-10-03T21:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom behavioural event for button click</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1050250#M77123</link>
      <description>&lt;P&gt;Then you just need to trigger the .submit() event for the form.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 14:56:51 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1050250#M77123</guid>
      <dc:creator>MrJustinGivens</dc:creator>
      <dc:date>2024-10-04T14:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating custom behavioural event for button click</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1077735#M78694</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/16592"&gt;@MrJustinGivens&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I figured out that essentially you cannot create CBE's for preference pages. The HS team told me those pages dont support it.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 15:58:31 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Creating-custom-behavioural-event-for-button-click/m-p/1077735#M78694</guid>
      <dc:creator>Mrafey</dc:creator>
      <dc:date>2024-12-02T15:58:31Z</dc:date>
    </item>
  </channel>
</rss>

