Traffic Source is Incorrect for API Form post



I’m currently only getting Direct Traffic for the Traffic Source on api form posts. I know you probably get this a lot, but I’ve gone through a lot of the documentation, as well as other posts on this subject, and I still feel like I don’t know what the problem is. I’m using c# with mvc

The API post is fine (as in I get all the correct values for everything else), and I include Request.Cookies[“hubspotutk”].Value (which I checked to make sure it is giving a value) in hsContext Dictionary when posting the data. I’ve made sure that cookies are not disabled on the form as well as in the report settings. I’ve also viewed the source of the page, and made sure that the javascript is included just before the closing body tag on every page, including the one where I post the data. However, despite that, traffic source is still always Direct Traffic.

Please let me know if anymore information is needed


Hi @Garrett

Are you passing the context data in a hsContext field or hs_context? Your post mentions hsContext but you would need to use hs_context.

If you are using hs_context, do you have an example of the actual POST data you’re using?


Hi @dadams,

Thank you for answering. My Dictionary variable is called hsContext as shown on

Dictionary<string, string> hsContext = new Dictionary<string, string>();
hsContext.Add(“hutk”, strHubSpotUTK);
hsContext.Add(“ipAddress”, strIpAddress);

but I post it as “hs_context”

// Append HS Context JSON
strPostData += "hs_context=" + Server.UrlEncode(strHubSpotContextJSON);

Here’s the hs_context post data (was on localhost):


and the StrPostData value looks like this:



Thanks @Garrett. Do you have an example contact I could take a look at? The POST data looks correct, but something else may be going on with the contacts.


Not sure if it’s just a coincidence that it didn’t look like it was working before. But I checked the contacts list, and the last hour has actually given accurate values (or rather, values other than Direct Traffic). In the last hour, I see Organic Search and Paid Search results now, though the last 100+ contacts (before the most recent change) are all Direct Traffic.

So I think it’s working… Thank you for the help