<?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: `hsFormCallback` for hubspot form embedded in Pop-up CTA in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/1037182#M40572</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/364212"&gt;@KyleCombs&lt;/a&gt;&amp;nbsp;I had the same issue and I found your post. Fortunately, I was able to find the message for submitting CTA forms by logging the message object in the console.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;
  window.addEventListener("message", function(event) {
    if(event.data.type === 'hsCallsToActionCallback' &amp;amp;&amp;amp; event.data.eventName === "onCallToActionFormSubmitted") {
      console.log(event.data);
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({
       'event': 'syllabus_request',
       'location': 'homepage',
       });
    }
  });
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;the type is&amp;nbsp;hsCallsToActionCallback and the eventName is&amp;nbsp;onCallToActionFormSubmitted. &lt;A href="https://developers.hubspot.com/docs/api/calls-to-action-sdk#events" target="_blank" rel="noopener"&gt;Hubspot has docs on the events&lt;/A&gt; for their SDK&amp;nbsp; but it's not exactly how they appear in the messages of the iframe for the CTA. also this appears to be new so maybe it wasn't there when you were attempting this back in January. Hopefully one day Hubspot will acknowlege the existence of advertising pixels and tracking software on marketing websites, but console.log(event.data) will have to do in the meantime.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 05 Sep 2024 19:56:46 GMT</pubDate>
    <dc:creator>EdCupaioli</dc:creator>
    <dc:date>2024-09-05T19:56:46Z</dc:date>
    <item>
      <title>`hsFormCallback` for hubspot form embedded in Pop-up CTA</title>
      <link>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/767234#M33255</link>
      <description>&lt;P&gt;Hello all. I have some datalayer pushes happening after a hubspot form submission on my site, and they are working just fine when the form is on the actual page, but I'm having issues when the form is in a Pop-Up CTA. Even though I'm using the same form in both places, when the form is in the Pop-Up CTA, it doesn't seem to be sending the hsFormCallback message to the window object like it does it does when the form is embedded right on the page. Is there a work around for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;&amp;lt;script&amp;gt;
  window.addEventListener("message", function(event) {
    if(event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === "onFormSubmit") {
      console.log(event.data);
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({
       'event': 'syllabus_request',
       'location': 'homepage',
       });
    }
  });
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 17:50:16 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/767234#M33255</guid>
      <dc:creator>KyleCombs</dc:creator>
      <dc:date>2023-03-10T17:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: `hsFormCallback` for hubspot form embedded in Pop-up CTA</title>
      <link>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/767696#M33269</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/364212"&gt;@KyleCombs&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;12:41 PM&lt;BR /&gt;It's possible that the issue is related to the fact that the Pop-Up CTA is loaded in an iframe, which can sometimes prevent messages from being sent between the iframe and the parent window. One workaround is to add the event listener to the iframe itself rather than the parent window.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Here's an example code snippet that you can try:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var iframe = document.querySelector('.hs-form-iframe');
if(iframe) {
  iframe.addEventListener("message", function(event) {
    if(event.data.type === 'hsFormCallback' &amp;amp;&amp;amp; event.data.eventName === "onFormSubmit") {
      console.log(event.data);
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({
        'event': 'syllabus_request',
        'location': 'homepage',
      });
    }
  });
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code assumes that the Pop-Up CTA is loaded in an iframe with the class "hs-form-iframe". You can replace this with the actual class or ID of the iframe in your Pop-Up CTA.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Also note that you may need to adjust the code to handle different types of messages that are sent between the iframe and the parent window, if your Pop-Up CTA is using other types of messages.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 07:17:20 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/767696#M33269</guid>
      <dc:creator>himanshurauthan</dc:creator>
      <dc:date>2023-03-13T07:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: `hsFormCallback` for hubspot form embedded in Pop-up CTA</title>
      <link>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/775129#M33513</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/20405"&gt;@himanshurauthan&lt;/a&gt;&amp;nbsp;, thanks for your reply.&amp;nbsp; It did get me to a working solution using a couple nested MutationObservers to isolate the iframe as Hubspot rendered it to the DOM.&amp;nbsp; As of this week it seems the iframe for my Pop-up CTA is actually rendered to the DOM on page load, but now I'm getting cross-origin errors trying to add event listeners to the iframe.&amp;nbsp; I understand the whole Pop-up CTA piece is stil lin Beta and may continue to change, but I'm curious why I was able to add an event listener to the iframe before, but now it is being blocked.&amp;nbsp; Any thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;script&amp;gt;
  window.addEventListener('load', function () {
    console.log('window', window);
    var hsIframeDiv = document.querySelector("#hs-overlay-cta-102529447332");
    var hsIframe = hsIframeDiv.firstChild;
    console.log('hsIframe: ', hsIframe);

    hsIframe.contentWindow.addEventListener("message", function(event) {
      console.log('message event', event)
    });
  });
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error I'm getting is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Uncaught DOMException: Blocked a frame with origin "https://my-domain" from accessing a cross-origin frame.&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 28 Mar 2023 19:21:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/775129#M33513</guid>
      <dc:creator>KyleCombs</dc:creator>
      <dc:date>2023-03-28T19:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: `hsFormCallback` for hubspot form embedded in Pop-up CTA</title>
      <link>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/907650#M37498</link>
      <description>&lt;P&gt;Any luck here Kyle? I am in the same situation. Did you find a solution to bypass the CORS error? Do we have a seeting we can set to allowlist desired domains?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 14:02:33 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/907650#M37498</guid>
      <dc:creator>RobertBardan</dc:creator>
      <dc:date>2024-01-18T14:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: `hsFormCallback` for hubspot form embedded in Pop-up CTA</title>
      <link>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/907670#M37500</link>
      <description>&lt;P&gt;Unfortunately no,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/392603"&gt;@RobertBardan&lt;/a&gt;. We just ended up scrapping the attempt and are hoping to retry once this feature is no longer in beta.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 14:12:17 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/907670#M37500</guid>
      <dc:creator>KyleCombs</dc:creator>
      <dc:date>2024-01-18T14:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: `hsFormCallback` for hubspot form embedded in Pop-up CTA</title>
      <link>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/1037182#M40572</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/364212"&gt;@KyleCombs&lt;/a&gt;&amp;nbsp;I had the same issue and I found your post. Fortunately, I was able to find the message for submitting CTA forms by logging the message object in the console.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;
  window.addEventListener("message", function(event) {
    if(event.data.type === 'hsCallsToActionCallback' &amp;amp;&amp;amp; event.data.eventName === "onCallToActionFormSubmitted") {
      console.log(event.data);
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({
       'event': 'syllabus_request',
       'location': 'homepage',
       });
    }
  });
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;the type is&amp;nbsp;hsCallsToActionCallback and the eventName is&amp;nbsp;onCallToActionFormSubmitted. &lt;A href="https://developers.hubspot.com/docs/api/calls-to-action-sdk#events" target="_blank" rel="noopener"&gt;Hubspot has docs on the events&lt;/A&gt; for their SDK&amp;nbsp; but it's not exactly how they appear in the messages of the iframe for the CTA. also this appears to be new so maybe it wasn't there when you were attempting this back in January. Hopefully one day Hubspot will acknowlege the existence of advertising pixels and tracking software on marketing websites, but console.log(event.data) will have to do in the meantime.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 19:56:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/hsFormCallback-for-hubspot-form-embedded-in-Pop-up-CTA/m-p/1037182#M40572</guid>
      <dc:creator>EdCupaioli</dc:creator>
      <dc:date>2024-09-05T19:56:46Z</dc:date>
    </item>
  </channel>
</rss>

