Pass a Score from a Game to a Hidden Hubspot Form Field


Has anyone been able or is it possible to pass a value to a hidden custom hubspot form field?

Game score = 10,000 then passs 10000 to game_score.



Hi Mark,

I am going to assume that you have jQuery on the page for this, but it can easily be adapted to vanilla.

if you have an update score function, you can do this to populate the form field:

function updateGameScore() {
	/* Your code here */
	$('input[name="game_score"]').val( theGameScore );

Of if you need to grab the score on form submit, you can also do this:

	portalId: '',
	formId: '',
	onFormSubmit: function($form) {
		$('input[name="game_score"]', $form).val( theGameScore );

To answer the second part of the question, to convert 10,000 to 10000 I would use this:

var hs_score = parseInt(score.replace(/\,/g,''))

Where score is the string 10,000


Was this to import a score from a third party system into Hubspot?


Sort of. This would be code on the page like a quiz or a game that someone would play on the page, and this would allow the score to be passed in a HubSpot form. The first method allows the game function to run and add the score whenever you display/calculate it (if you have it setup that way, or don’t have access to the form embed code). The second option allows you to get the score total when you submit the HubSpot form, if you have access to the embed object.


Which API would you use to add score to Hubspot instance? Would it populate a Contact field?


I would recommend checking out this endpoint

This will allow you to update contacts properties. The examples above are for using the Form embed codes.


Thank you. This is helpful!