When I add a new contact using the API, it shows the following message in my contact tab:
( This contact was created from Offline Sources from API )
Is there a way for me to customize this message, let’s say. (This contact was created from offline sources from API using the form “XYZ” )
I have a custom property set up to see where the user is coming from, but I would like to show it in this message as well.
In this case it should show ( This contact was created using “Seller’s guide” .) or something related to that.
(screen grab added for context)
Hi @Aizaz ,
If you use the Form Submission API and pass it the hubspotutk cookie value in the hutk parameter, than it will create the contact correctly with all tracking data available (pages visited, organic source / ads etc.).
Just use this API (I can share a postman collection) together with the tracking script.
I would really much appreciate if you could share the postman collection.
Hi Aizaz,
What programming language do you use? Might be easier to just share the code with you.
I’m Using TypeScript /Js (Angular).
Hi @Aizaz ,
Cool! See the code below, I used JavaScript with Fetch, but could also share NodeJS with Axios if you want:
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"submittedAt": "1636460999000", // Unix timestamp of the submission date / time
"fields": [
{
"name": "email",
"value": "example@example.com"
},
{
"name": "firstname",
"value": "John"
},
{
"name": "lastname",
"value": "Doe"
},
{
"name": "phone",
"value": "0600000000"
},
{
"name": "city",
"value": "Amsterdam"
},
{
"name": "zip",
"value": "1234AB"
}
],
"context": {
"hutk": "XXXX", // This should get the value of the "hubspotutk" cookie value
"pageUri": "https://example.com",
"pageName": "Example page"
},
"legalConsentOptions": {
"consent": {
"consentToProcess": true,
"text": "I agree to allow Example Company to store and process my personal data.",
"communications": [
{
"value": true,
"subscriptionTypeId": 999,
"text": "I agree to receive marketing communications from Example Company."
}
]
}
}
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.hsforms.com/submissions/v3/integration/submit/<Portal ID>/<Form ID>", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
If you take a look at the docs, you can customize the “legalConsentOptions” to fit your need. Make sure that all passed values in the “fields” objects also exists as properties in HubSpot.
Thanks mate!
