APIs & Integrations

catalin_oanca
Member

Submit data to a form, wrong original source

SOLVE

Hi,

Using the documentation provided here: https://developers.hubspot.com/docs/methods/forms/submit_form

I managed to send data to a hubspot form, with the only issue that the original source it’s incorrect.

I cleared cookies, simulated a visitor coming from another website, even added tracking URL like ?utm_source=facebook&utm_medium=social&utm_campaign=xyz but every time the original source is set as Direct Traffic and Original source drill-down 1 is set to the page added in the $hs_context ( ‘pageUrl’ ) Also First page seen is set to the same URL

I expect that URL to be the URL the form is submitted on and not the Original Source.

What am I doing wrong?

Full Code

//Process a new form submission in HubSpot in order to create a new Contact.

$hubspotutk = $_COOKIE[‘hubspotutk’]; //grab the cookie from the visitors browser.
$ip_addr = $_SERVER[‘REMOTE_ADDR’]; //IP address too.
$hs_context = array(
‘hutk’ => $hubspotutk,
‘ipAddress’ => $ip_addr,
‘pageUrl’ => ‘https://random.url’,
‘pageName’ => ‘Lead Form’
);
$hs_context_json = json_encode($hs_context);

//Need to populate these variable with values from the form.
$str_post = “firstname=” . urlencode($full_name)
. “&lastname=” . urlencode($full_name)
. “&email=” . urlencode($email_address)
. “&phone=” . urlencode($phone_number)
. “&hs_context=” . urlencode($hs_context_json); //Leave this one be

//replace the values in this URL with your portal ID and your form GUID
$endpoint = ‘removed for privacy’;

$ch = #curl_init();
#curl_setopt($ch, CURLOPT_POST, true);
#curl_setopt($ch, CURLOPT_POSTFIELDS, $str_post);
#curl_setopt($ch, CURLOPT_URL, $endpoint);
#curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Content-Type: application/x-www-form-urlencoded’
));
#curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
#curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = #curl_exec($ch); //Log the response from HubSpot as needed.
$status_code = #curl_getinfo($ch, CURLINFO_HTTP_CODE); //Log the response status code
$curlerror = #curl_error($ch);
#curl_close($ch);

I had to replace @ with # for this topic so I can post the message (new user limitations)

0 Upvotes
1 Accepted solution
catalin_oanca
Solution
Member

Submit data to a form, wrong original source

SOLVE

@Derek_Gervais I figured it out.
I had “Limit tracking to these domains” enabled under my account and I was doing testing on a development domain, not the production website, that’s why the information wasn’t accurate.

Doing the test on production seems to work just fine.

Thanks for your assistance.

View solution in original post

6 Replies 6
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Submit data to a form, wrong original source

SOLVE

Hi @catalin.oanca,

That makes sense, thanks for reaching back out here with an update!

0 Upvotes
catalin_oanca
Solution
Member

Submit data to a form, wrong original source

SOLVE

@Derek_Gervais I figured it out.
I had “Limit tracking to these domains” enabled under my account and I was doing testing on a development domain, not the production website, that’s why the information wasn’t accurate.

Doing the test on production seems to work just fine.

Thanks for your assistance.

catalin_oanca
Member

Submit data to a form, wrong original source

SOLVE

@Derek_Gervais I sent you a private message with login info to a staging environment where we can test this better

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Submit data to a form, wrong original source

SOLVE

Hi @catalin.oanca,

I submitted that form, but it looks like it was using zapier instead of the forms API? Is it possible that I submitted the wrong form?

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Submit data to a form, wrong original source

SOLVE

Hi @catalin.oanca,

Can you post a link to the page with the form you’re referring to? I’d like to take a closer look.

0 Upvotes
catalin_oanca
Member

Submit data to a form, wrong original source

SOLVE

Hi @Derek_Gervais,

Thank you for your reply.
This is the form https://goo.gl/zbhEGn

0 Upvotes