How to set the source of a deal

Hello,

I build an automation for a custom website form (no hubspot form), so that it creates a contact, a deal of the form and an association between those two objects via the API based on the inputs. It works perfectly so far but my problem is, how to add a original source to the deal. I want to know from which source the user comes (directly, Google, Email, specific ad…).

I’ve installed your tracking pixel and it seems to track all those informations but my problem is, how to refer this data to a specific deal. Is there a possibility to add sources for a deal via the API?

Hi, @Cojohnny :waving_hand: Thanks for the interesting question. I have a few questions to get us started:

  • Q1 – Is the Contact, when created, getting its Original Source set? Or is it not being set for both the Contact and the Deal?
  • Q2 – For this question, “Is there a possibility to add sources for a deal via the API?” are you wanting the Source to be appended or set via an endpoint after the Deal is created?

For Q2 – you can update the values set for Original source using a PATCH request like this:

curl --request PATCH \
 --url https://api.hubapi.com/crm/v3/objects/deals/9786091184 \
 --header 'authorization: Bearer YOUR_ACCESS_TOKEN' \
 --header 'content-type: application/json' \
 --data '{
 "properties": {
 "hs_analytics_source": "SOCIAL_MEDIA"
 }
}'

Additionally, take a look at this thread from our champion @karstenkoehler which gives a great breakdown of how source is inherited from an associated contact or company depending on the situation — How to track the exact source for Deals?

If this is not what you are looking for, please add more details, and we’ll see if the community can assist.

Best,

Jaycee

Hello Jaycee,

thanks for your answer.

Q1: No it doesnt get any source information neither for contacts nor for deals. This may be due to the fact that I do not request the Hubspot-API directly from the client. I use a google cloud function to validate the input and then do a safe request to the API. Is it possible that the source information will be lost during this process and is there a possibility to fix this?

Q2: Thanks for referring to the endpoint, I haven’t found the property “hs_analytics_source” in the docs. I actually want to append the source information when creating a deal but I don’t know exactly how to analyse what source the visitior is coming from.