{"id":237,"date":"2022-04-20T08:44:59","date_gmt":"2022-04-20T08:44:59","guid":{"rendered":"https:\/\/theatlass.com\/resources\/?post_type=docs&#038;p=237"},"modified":"2022-05-18T11:17:25","modified_gmt":"2022-05-18T11:17:25","slug":"track-hubspot-forms","status":"publish","type":"docs","link":"https:\/\/theatlass.com\/resources\/docs\/track-hubspot-forms\/","title":{"rendered":"Track HubSpot Forms"},"content":{"rendered":"\n<p>In the article below I&#8217;m gonna show you how to track HubSpot forms.<\/p>\n\n\n\n<p>After creating the form inside your HubSpot account, you will be prompted with a code to embed on your website:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1025\" height=\"654\" src=\"https:\/\/theatlass.com\/resources\/wp-content\/uploads\/2022\/04\/image-10.png\" alt=\"\" class=\"wp-image-239\" srcset=\"https:\/\/theatlass.com\/resources\/wp-content\/uploads\/2022\/04\/image-10.png 1025w, https:\/\/theatlass.com\/resources\/wp-content\/uploads\/2022\/04\/image-10-300x191.png 300w, https:\/\/theatlass.com\/resources\/wp-content\/uploads\/2022\/04\/image-10-768x490.png 768w\" sizes=\"(max-width: 1025px) 100vw, 1025px\" \/><\/figure>\n\n\n\n<p>In order to get the submitted data, make sure to add this code after the formId property. This will send the form data to the redirect URL as query string parameters.<\/p>\n\n\n<div class=\"wp-block-lazyblock-script-code-block lazyblock-script-code-block-Z1F2nQF\"><div class=\"code-block w-100\" >\n<pre class=\"wp-block-code\" id=\"hubspot\" >\n  ,onFormSubmit: function($form) {\n     let redirectUrl = JSON.parse( $form[0].elements.hs_context.value ).redirectUrl;\n     if( redirectUrl ){\n            redirectUrl += (( redirectUrl.includes(\"?\") ) ? \"&\"+ $form.serialize() : \"?\"+ $form.serialize() )\n            window.location = redirectUrl\n     }\n }<\/pre>\n<a data-copy=\"hubspot\" class=\"btn-copy-script\"> <i class=\"far fa-copy\"><\/i>  <\/a>\n<\/div>\n<\/div>\n\n\n<p>The final code should look like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"745\" height=\"192\" src=\"https:\/\/theatlass.com\/resources\/wp-content\/uploads\/2022\/04\/image-13.png\" alt=\"\" class=\"wp-image-242\" srcset=\"https:\/\/theatlass.com\/resources\/wp-content\/uploads\/2022\/04\/image-13.png 745w, https:\/\/theatlass.com\/resources\/wp-content\/uploads\/2022\/04\/image-13-300x77.png 300w\" sizes=\"(max-width: 745px) 100vw, 745px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In the article below I&#8217;m gonna show you how to track HubSpot forms. After creating the form inside your HubSpot account, you will be prompted with a code to embed on your website: In order to get the submitted data, make sure to add this code after the formId property. This will send the form [&hellip;]<\/p>\n","protected":false},"featured_media":0,"menu_order":6,"template":"","meta":[],"_links":{"self":[{"href":"https:\/\/theatlass.com\/resources\/wp-json\/wp\/v2\/docs\/237"}],"collection":[{"href":"https:\/\/theatlass.com\/resources\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/theatlass.com\/resources\/wp-json\/wp\/v2\/types\/docs"}],"wp:attachment":[{"href":"https:\/\/theatlass.com\/resources\/wp-json\/wp\/v2\/media?parent=237"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}