# Submit data to a form, wrong original source

**URL:** <https://community.hubspot.com/t/submit-data-to-a-form-wrong-original-source/12010>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [February 5, 2018, 10:47am UTC](https://community.hubspot.com/t/submit-data-to-a-form-wrong-original-source/12010 "2018-02-05T10:47:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [February 5, 2018, 10:47am UTC](https://community.hubspot.com/t/submit-data-to-a-form-wrong-original-source/12010/1 "2018-02-05T10:47:03Z")

</div>

Hi,

Using the documentation provided here: [https://developers.hubspot.com/docs/methods/forms/submit\_form](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](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)

---

<div class="post-metadata">

**Author:** ![Derek\_Gervais](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/derek_gervais/32/17429_2.png) [@Derek\_Gervais](https://community.hubspot.com/u/Derek_Gervais)\
**Post date:** [February 6, 2018, 11:20pm UTC](https://community.hubspot.com/t/submit-data-to-a-form-wrong-original-source/12010/2 "2018-02-06T23:20:49Z")

</div>

Hi [@catalin.oanca](https://community.hubspot.com/u/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.

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [February 9, 2018, 7:25am UTC](https://community.hubspot.com/t/submit-data-to-a-form-wrong-original-source/12010/3 "2018-02-09T07:25:05Z")

</div>

Hi [@Derek\_Gervais](https://community.hubspot.com/u/derek_gervais),

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

---

<div class="post-metadata">

**Author:** ![Derek\_Gervais](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/derek_gervais/32/17429_2.png) [@Derek\_Gervais](https://community.hubspot.com/u/Derek_Gervais)\
**Post date:** [February 9, 2018, 9:00pm UTC](https://community.hubspot.com/t/submit-data-to-a-form-wrong-original-source/12010/4 "2018-02-09T21:00:52Z")

</div>

Hi [@catalin.oanca](https://community.hubspot.com/u/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?

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [February 12, 2018, 8:55am UTC](https://community.hubspot.com/t/submit-data-to-a-form-wrong-original-source/12010/5 "2018-02-12T08:55:11Z")

</div>

[@Derek\_Gervais](https://community.hubspot.com/u/derek_gervais) I sent you a private message with login info to a staging environment where we can test this better

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [February 13, 2018, 8:27am UTC](https://community.hubspot.com/t/submit-data-to-a-form-wrong-original-source/12010/6 "2018-02-13T08:27:57Z")

</div>

[@Derek\_Gervais](https://community.hubspot.com/u/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.

---

<div class="post-metadata">

**Author:** ![Derek\_Gervais](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/derek_gervais/32/17429_2.png) [@Derek\_Gervais](https://community.hubspot.com/u/Derek_Gervais)\
**Post date:** [February 13, 2018, 10:50pm UTC](https://community.hubspot.com/t/submit-data-to-a-form-wrong-original-source/12010/7 "2018-02-13T22:50:16Z")

</div>

Hi [@catalin.oanca](https://community.hubspot.com/u/catalin.oanca),

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