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.
Here’s what the POST body looks like when submitting the form through the Form API:
{
“email”: "test@test.com",
“firstname”: “Tester”,
“hs_context”:
{
“hutk”: “0f9abb06328e07b16e16f3571b30c31e”,
“pageUrl”: “http://test.com/signup”,
“pageName”: “My Page”,
“redirectUrl”: “https://test.com/done”,
“ipAddress”: “127.0.0.1”
}
}
Leads showing up as Direct Traffic when they aren't, via Forms API
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.
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.
Leads showing up as Direct Traffic when they aren't, via Forms API
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.
So, the official example of a full body should instead be: firstname%3DTestContact%26lastname%3DFormSub%26email%3Dformsub%40hubspot.com%26newcustomproperty%3Dtesting%26hs_context%3D%7B%22hutk%22%3A%2260c2ccdfe4892f0fa0593940b12c11aa%22%2C%22ipAddress%22%3A%22192.168.1.12%22%2C%22pageUrl%22%3A%22http%3A%2F%2Fdemo.hubapi.com%2Fcontact%2F%22%2C%22pageName%22%3A%22Contact%2BUs%22%2C%22redirectUrl%22%3A%22http%3A%2F%2Fdemo.hubapi.com%2Fthank-you%2F%22%7D
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):