Leads showing up as Direct Traffic when they aren't, via Forms API


We have potential clients land on our Wordpress site, where the the utm_campaign/utm_source params are on the url. Then we sent them to our webapp once they enter their name/email. The webapp then uses the Form API to submit their name/email to Hubspot, but everyone is showing up as Direct Traffic, as opposed to part of our campaigns.

We’re passing the hutk cookie as described on https://developers.hubspot.com/docs/methods/forms/submit_form but it has not added any information.

Here’s what the POST body looks like when submitting the form through the Form API:
“email”: "test@test.com",
“firstname”: “Tester”,
“hutk”: “0f9abb06328e07b16e16f3571b30c31e”,
“pageUrl”: “http://test.com/signup”,
“pageName”: “My Page”,
“redirectUrl”: “https://test.com/done”,
“ipAddress”: “”


Hi @robin_izea

Are you sending the data as JSON or as form-encoded data? You would need to use form-encoded data for this.

If you are sending the data as form-encoded, do you have an example of the form-encoded data you’re sending? There might be an issue converting that JSON into the form data.


Yes, it is being form-encoded. Here is what the data looks like once form-encoded:



Is there anything else we can try on our end to get the Original Source to show up as something other than Direct Traffic?

I see here that it should even pick up things like search terms that landed the user on our site, but it isn’t.

Here’s another example of a flow that isn’t getting the Original Source set properly:

  • Brand new browser session, with all cookies cleared
  • Search in Google for our sign up page, click link to get to our Wordpress site
  • Our Wordpress site has your tracking JS snippet, which I assume is what then sets the ‘hubspotutk’ cookie (I’ve confirmed the cookie is now set)
  • Filling out our html form on Wordpress lands the user on our webapp to complete the sign up process
  • On the webapp, we submit what is in the above post via your Form API, including the ‘hubspotutk’ cookie
  • On the Hubspot Form dashboard, there is now a new entry for that name/email, but their Original Source is incorrectly listed as Direct Traffic


@robin_izea the hs_context value looks incorrect. If I decode the value you have I get:


which isn’t valid JSON. For those same values, you’d need to have something like this:


which would decode to

{“hutk”:“0f9abb06328e07b16e16f3571b30c31e”,“pageUrl”:“http://test.com/signup",“pageName”:"My Page”,“redirectUrl”:“https://test.com/done",“ipAddress”:"”}


Thank you for your reply. In early testing, this change has already resulted in the “pageName” (adjacent to the cookie) showing up on your dashboard from this call, so I am hopeful the other issue will be also be fixed once we deploy this.

Please be aware that the way we had implemented it previously (with the “+” as spaces in the JSON) is exactly as the example in the official documentation’s example has it at https://developers.hubspot.com/docs/methods/forms/submit_form .

So, the official example of a full body should instead be:

If you’ve arrived here and are also writing in Ruby, consider running the following on your form data before submitting it (and consider using Faraday):

form_data["hs_context"] = form_data["hs_context"].to_json


Thanks @robin_izea, I’ll make sure the documentation gets updated.


Hi @dadams, thank you for all your helpful responses regarding tracking traffic source through the Form API. Our campaign landing page to web app flow is very similar to robin’s , but we have a slightly different issue.

Here’s an example of a lead’s journey:

  1. lead sees our link on a referral site: https://www.producthunt.com/alternatives/marvel-2-0-2
  2. lead clicks on the “GET IT” link under “Brandcast”
  3. the link takes lead to our landing page: https://brandcast.com/?ref=producthunt
  4. lead clicks on one of the “try for free” links on the landing page
  5. the link takes the lead to our signup page which is on our web app under a different domain: https://app.brandcast.io/signup
  6. after the lead signs up, a contact like this one is created: https://app.hubspot.com/contacts/2712945/contact/63251/

As you can see the contact traffic source is recorded as “Direct Traffic” while we are certain that the lead went through the flow above.

We have the hubspot tracking code deployed via google tag manager on both the landing page and the signup page (although under different domains). We are fairly confident that we are sending the hutk data correctly because a couple of contacts are showing the correct traffic source, for example:

We think these leads might have clicked on ads that show links directly to our web app signup page which might explain the correct traffic source.

Here’s an example of the form API request body:


Could you provide some insight into why the traffic source is not correct when the leads go through our landing pages then to our web app signup page?

Thank you


NVM @dadams, we figured it out. We had to enable the “Automatic cross-domain linking” option in the hubspot tracking code according to this article: https://knowledge.hubspot.com/articles/kcs_article/settings/can-i-track-multiple-domains-with-hubspot