How to Enable Cookie Tracking For HubSpot Forms
HubSpot uses a cookie called hubspotutk to track users. To enable cookie tracking on your FormCrafts forms, you have to modify the form embed code.
Our original form embed code looks like this:
<script type='text/javascript'>var _fo=_fo?_fo:[]; _fo.push({'c':'nigoc','i':'formid','m':0,'s':0,'w':504}); if (typeof fce=='undefined') {var s=document.createElement('script'); s.type='text/javascript'; s.async=true; s.src='https://formcrafts.com/js/fc.js'; document.body.appendChild(s);fce=1;}</script> <div id='nigoc' style='height:838px'></div>
To enable cookie tracking add the text in bold to your embed code:
<script type='text/javascript'>var _fo=_fo?_fo:[]; _fo.push({'c':'nigoc','i':'formid'+'?hubspotutk='+document.cookie.replace(/(?:(?:^|.*;s*)hubspotutks*=s*([^;]*).*$)|^.*$/, "$1"),'m':0,'s':0,'w':504}); if (typeof fce=='undefined') {var s=document.createElement('script');s.type='text/javascript'; s.async=true; s.src='https://formcrafts.com/js/fc.js'; document.body.appendChild(s);fce=1;}</script> <div id='nigoc' style='height:838px'></div>
Note that formid in the above examples would be the actual ID of your form.
Originally published September 23, 2021 1:30 pm. Updated September 24, 2022.