Hello, I am using the following request to post form data to my hubspotforms: https://developers.hubspot.com/docs/methods/forms/submit_form
In the documentation it says i need to add my hubspotutk to the hutk field under context like this:
“context”: {
Can you confirm, that you’re actually capturing and pushing the hutk value rather than just adding this code? This code is not complete but is rather used as a template of how data should be submitted.
In this case, we show how the request payload should be structured when using this endpoint. You will still need to design the functionality to handle the hutk cookie and pass it in this payload.
To assist, you’ll need something that functions similar to this code:
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
This is a simple script to retrieve a cookie value (cname). You’ll need to create something similar to handle the hutk value, once returned, you’ll need to ensure it is passed in the request payload.
sorry for the confusion, I knew it was a snippet/example but I retrieved the cookie value just like the way you suggested and passed it in like this:
“context”: {
“hutk”: “retrievedcookievalue”,
“pageUri”: document.URL
“pageName”: document.title
},
I have a hunch that i need to put something else instead of “hutk”?
edit: contacted chat and told me i need to use hs_context. Is this the right approach?
Nevermind… Looks like I read it wrong. there was an error in my field just like the error said “htuk” is indeed not a valid attribute it needs to be “hutk”.
It works now. Thank you for your time to respond Matthew.