Hotjar experience on Unbounce pages?



Show first post

29 replies

Anyone get successful form submits in HotJar?  Anyone know how to override Unbounce’s form submission, so I can add the HotJar script they provide for manual submit tracking?

I have a working script thanks to the help of my developer pal at work. This should work on any page as long as the normal Hotjar script and this script load on your desired page. I prefer to do this through the Settings > Scripts menu.

<script type="text/javascript">
	lp.jQuery(function($) {
		function notifyHotjar() {
			lp.jQuery('.lp-pom-form form').submit();
			hj('formSubmit' + ($('.lp-pom-form form').valid() ? 'Successful' : 'Failed'));
		}

		$('.lp-pom-form .lp-pom-button')
			.unbind('click tap touchstart')
			.bind('click.formSubmit', notifyHotjar); 

		$('form')
			.unbind('keypress')
			.bind('keypress.formSubmit', function(e) {
				if(e.which === 13 && e.target.nodeName.toLowerCase() !== 'textarea' ) {
					notifyHotjar();
				}
			});
	});
</script>

Best,
Brian

Userlevel 7
Badge +1

Brian this is awesome, thanks so much for sharing this!!

This is Tips & Scripts worthy - would you mind if we shared this in there?

-Jess

Go for it. I’d be curious to have some others try the script and also review it for any potential issues.

Reply