Home / Admin / Edits to HubSpot Form Embed to make it work within OptinMonster campaigns.
Duplicate Snippet

Embed Snippet on Your Site

Edits to HubSpot Form Embed to make it work within OptinMonster campaigns.

Code Preview
universal
!--[if lte IE 8]
  <script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"></script>
  <![endif]-->
<script>
  (function() {
  	var addForm = function() {
  		window.hbspt.forms.create({
  			sfdcCampaignId: '70130000000ep2ZZZ',
  			portalId: '102310',
  			formId: '190ga042-56fc-4897-bed4-86ea519cb3e9',
  			target: 'html div#om-{{id}} .custom-hubspot-form-{{id}}',
  			onFormSubmit($form, ctx){
				om{{id}}.Listeners.convert(); // Track submission as a conversion in OptinMonster
				om{{id}}.changeView('success'); // Show Success view on submission
				om{{id}}.startClose(); // OR close campaign on submission (remove one)
  			}
  		});
  	};
  
  	if (window.hbspt && window.hbspt.forms) {
  		return addForm();
  	}
  
  	// Inject the Hubspot script.
  	var script = document.createElement('script')
  	script.src = "//js.hsforms.net/forms/v2.js"
  	script.async = true
  	script.onload = addForm;
  	(document.getElementsByTagName('head')[0] || document.documentElement).appendChild(script)
  })();
</script>
<div class="custom-hubspot-form-{{id}}"></div>

Comments

Add a Comment