<?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: Issues capturing the hubspotutk cookie in form submission with HubSpot API in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-capturing-the-hubspotutk-cookie-in-form-submission-with/m-p/1128417#M81201</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/921059"&gt;@alexdeoliveira&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to confirm, you are using a custom coded form (not an embedded HubSpot form), correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You mention that you are trying to pass the cookie through a hidden variable. In your API call, are you passing the cookie value into the "fields" or the "context" object in the body?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 27 Mar 2025 13:23:25 GMT</pubDate>
    <dc:creator>evaldas</dc:creator>
    <dc:date>2025-03-27T13:23:25Z</dc:date>
    <item>
      <title>Issues capturing the hubspotutk cookie in form submission with HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-capturing-the-hubspotutk-cookie-in-form-submission-with/m-p/1128001#M81177</link>
      <description>&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Hey folks! I’m having an issue with capturing the &lt;SPAN class=""&gt;hubspotutk&lt;/SPAN&gt; cookie and sending it to HubSpot via API.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;I have a sign-up form in a Laravel app hosted at &lt;SPAN class=""&gt;example.yourdomain.com&lt;/SPAN&gt;, and the HubSpot tracking script is being loaded via Google Tag Manager using a custom HTML tag:&lt;/P&gt;&lt;PRE&gt;&amp;lt;script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/XXXXXXXX.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;P class=""&gt;In GTM, the trigger is set to fire on pages where the hostname contains “yourdomain.com”, so it should include &lt;SPAN class=""&gt;example.yourdomain.com&lt;/SPAN&gt;.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;In the form, I try to capture the &lt;SPAN class=""&gt;hubspotutk&lt;/SPAN&gt; cookie using JavaScript and set it into a hidden input before submitting.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;I even added a 2-second delay on the form’s submit event to give the cookie time to load before sending the data.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Still, when the form is submitted and data is sent using the HubSpot Forms API (&lt;SPAN class=""&gt;&lt;A href="https://api.hsforms.com/submissions/v3/integration/secure/submit/" target="_blank" rel="noopener"&gt;https://api.hsforms.com/submissions/v3/integration/secure/submit/&lt;/A&gt;...&lt;/SPAN&gt;), most of the submissions come with a null &lt;SPAN class=""&gt;hutk&lt;/SPAN&gt;, and they show up in HubSpot as direct traffic.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;I’ve logged the values before sending, double-checked GTM and script timing — everything seems to be working, except I’m not getting that cookie. I’ve seen some people mention browser tracking prevention might block the cookie, but the percentage is way too high for that to be the only reason.&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Has anyone run into this before? Any tips to make sure the &lt;SPAN class=""&gt;hubspotutk&lt;/SPAN&gt; gets captured and properly sent with the API submission? Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Mar 2025 18:01:39 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-capturing-the-hubspotutk-cookie-in-form-submission-with/m-p/1128001#M81177</guid>
      <dc:creator>alexdeoliveira</dc:creator>
      <dc:date>2025-03-26T18:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: Issues capturing the hubspotutk cookie in form submission with HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-capturing-the-hubspotutk-cookie-in-form-submission-with/m-p/1128417#M81201</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/921059"&gt;@alexdeoliveira&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to confirm, you are using a custom coded form (not an embedded HubSpot form), correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You mention that you are trying to pass the cookie through a hidden variable. In your API call, are you passing the cookie value into the "fields" or the "context" object in the body?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 13:23:25 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-capturing-the-hubspotutk-cookie-in-form-submission-with/m-p/1128417#M81201</guid>
      <dc:creator>evaldas</dc:creator>
      <dc:date>2025-03-27T13:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Issues capturing the hubspotutk cookie in form submission with HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-capturing-the-hubspotutk-cookie-in-form-submission-with/m-p/1128438#M81203</link>
      <description>Hi &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/53048"&gt;@evaldas&lt;/a&gt;, thanks for jumping in!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Yes, that’s correct — I’m using a *custom-coded form*, not an embedded&lt;BR /&gt;HubSpot form.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;In the API call, the hubspotutk cookie is being passed inside the *context*&lt;BR /&gt;object of the request body, like this:&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;"fields": [&lt;BR /&gt;{ "name": "email", "value": "example@example.com" },&lt;BR /&gt;{ "name": "firstname", "value": "John" },&lt;BR /&gt;...&lt;BR /&gt;],&lt;BR /&gt;"context": {&lt;BR /&gt;"hutk": "cookie_value_here",&lt;BR /&gt;"pageUri": "&lt;A href="https://dns.lumiun.com/register" target="_blank"&gt;https://dns.lumiun.com/register&lt;/A&gt;",&lt;BR /&gt;"pageName": "Create Account"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;So the structure seems correct — the main issue is that sometimes the&lt;BR /&gt;hubspotutk cookie is missing on the client side before submission, even&lt;BR /&gt;after trying to read it with a retry loop in JavaScript.&lt;BR /&gt;&lt;BR /&gt;Appreciate any ideas you might have on that!&lt;BR /&gt;</description>
      <pubDate>Thu, 27 Mar 2025 14:08:28 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-capturing-the-hubspotutk-cookie-in-form-submission-with/m-p/1128438#M81203</guid>
      <dc:creator>alexdeoliveira</dc:creator>
      <dc:date>2025-03-27T14:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Issues capturing the hubspotutk cookie in form submission with HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-capturing-the-hubspotutk-cookie-in-form-submission-with/m-p/1128469#M81208</link>
      <description>&lt;P&gt;Yes, the structure you have looks correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The question now is whether the issue is with one of the following:&lt;/P&gt;
&lt;P&gt;- the cookie value being captured by the JavaScript code&lt;/P&gt;
&lt;P&gt;- the cookie value being properly passed into request body&lt;/P&gt;
&lt;P&gt;- the cookie loading in the first place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Theoretically, the cookie should be available upon page load and you should be able to store it in a variable even before someone tries to fill out a form - so you should not really even need to delay the form submission.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest running some tests in separate incognito/private sessions to check whether the JS function is capturing it consistently/properly with a simple console log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;console.log('HubSpot Cookie:', your_cookie_variable_from_JS);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Mar 2025 15:09:01 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-capturing-the-hubspotutk-cookie-in-form-submission-with/m-p/1128469#M81208</guid>
      <dc:creator>evaldas</dc:creator>
      <dc:date>2025-03-27T15:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Issues capturing the hubspotutk cookie in form submission with HubSpot API</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/Issues-capturing-the-hubspotutk-cookie-in-form-submission-with/m-p/1131949#M81408</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/921059"&gt;@alexdeoliveira&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are a few things that you can check, sometimes because of these the cookies are not captured -&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Script Loading Order:&lt;/STRONG&gt; The HubSpot tracking script cannot be accessible even with a 2-second lag if it hasn't been loaded or completely initialized before you try to capture the cookie. Make sure that no other scripts are interfering with the loading of the GTM tag and that the tag firing is dependable.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Asynchronous Loading:&lt;/STRONG&gt; Because the script loads asynchronously, you may want to make sure the cookie is set before submitting the form by using a callback or event listener, if one is available.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-sheets-root="1"&gt;I hope this will help you out. Please mark it as &lt;STRONG&gt;Solution Accepted and upvote&lt;/STRONG&gt; to help another Community member.&lt;BR /&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Apr 2025 10:59:52 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/Issues-capturing-the-hubspotutk-cookie-in-form-submission-with/m-p/1131949#M81408</guid>
      <dc:creator>GRajput</dc:creator>
      <dc:date>2025-04-04T10:59:52Z</dc:date>
    </item>
  </channel>
</rss>

