# Non-hubspot forms working with

**URL:** <https://community.hubspot.com/t/non-hubspot-forms-working-with/43058>\
**Category:** CMS Development\
**Created:** [August 30, 2021, 2:57am UTC](https://community.hubspot.com/t/non-hubspot-forms-working-with/43058 "2021-08-30T02:57:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BWhittle](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/bwhittle/32/14279_2.png) [@BWhittle](https://community.hubspot.com/u/BWhittle)\
**Post date:** [August 30, 2021, 2:57am UTC](https://community.hubspot.com/t/non-hubspot-forms-working-with/43058/1 "2021-08-30T02:57:31Z")

</div>

I use Hubspot on my website, and Hubspot has their “non hubspot forms” where they use tracking code to pick up forms.

```lia-code-sample
<!-- Start of HubSpot Embed Code -->

<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/8070487.js"></script>

<!-- End of HubSpot Embed Code -->

```

However on one of my pages with WCFM it is not picking up the form. It picks up login forms, checkout forms, etc.

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [August 30, 2021, 8:05am UTC](https://community.hubspot.com/t/non-hubspot-forms-working-with/43058/2 "2021-08-30T08:05:02Z")

</div>

Hi @BWhittle!

HubSpot ignores certain forms if they contain sensitive fields. For example, forms with any creditcard information will be ignored. If you check the source code of [collectedform.js](https://js.hscollectedforms.net/collectedforms.js)

you will see that they ignore forms with a type, name or value that contains “credit card”, “card number”, “expiration”, “expiry”, “ccv”, “cvc”, “cvv”, “secure code”, “mastercard”, “american express”, “amex”.

If I read the source code correctly, they also ignore forms that contain a **password** field, they check for the name, attribute and type as well.

So this form is not collected because it contains an input with the **password** type.

I think you can fix this by creating a 2 step form, first collect the necessary details and use another form to set the password.

Another option is to use the API to collect form submissions instead.

---

<div class="post-metadata">

**Author:** ![BWhittle](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/bwhittle/32/14279_2.png) [@BWhittle](https://community.hubspot.com/u/BWhittle)\
**Post date:** [August 30, 2021, 3:31pm UTC](https://community.hubspot.com/t/non-hubspot-forms-working-with/43058/3 "2021-08-30T15:31:21Z")

</div>

Hi there,

Thank you for your aswer. How come non-Hubspot forms work on my login pages that have a password?

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [August 30, 2021, 5:18pm UTC](https://community.hubspot.com/t/non-hubspot-forms-working-with/43058/4 "2021-08-30T17:18:42Z")

</div>

@BWhittle That is a good question. I suppose collectedforms.js does retrieve form data with **password** inputs.

So lets analyze some differences between the 2 forms.

So the first two forms are native woocommerce forms right? And the second form seems to be created with a membership plugin for woocommerce correct?

If I check the form you are having issues with, there are no network requests triggered by HubSpot either.

If I try the register form on my-account, the form is send by, the [https://forms.hsforms.com/embed/v3/counters.gif?key=collected-forms-embed-js-submit-event&count=1](https://forms.hsforms.com/embed/v3/counters.gif?key=collected-forms-embed-js-submit-event&count=1) is called to collect the form.

So it might be the way the first form is send, or something in your form is blocking the form to be collected by HubSpot.

We have an woocommerce form as well, and we use a custom PHP script to send the form submissions to HubSpot instead. That could be your solution if you are up for some custom work.

---

<div class="post-metadata">

**Author:** ![BWhittle](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/bwhittle/32/14279_2.png) [@BWhittle](https://community.hubspot.com/u/BWhittle)\
**Post date:** [August 31, 2021, 3:56pm UTC](https://community.hubspot.com/t/non-hubspot-forms-working-with/43058/5 "2021-08-31T15:56:28Z")

</div>

Thanks so much for your response! Can you provide that PHP script?

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [September 1, 2021, 7:34am UTC](https://community.hubspot.com/t/non-hubspot-forms-working-with/43058/6 "2021-09-01T07:34:03Z")

</div>

@BWhittle  
It is an older script, the [API](https://legacydocs.hubspot.com/docs/methods/forms/submit_form) has changed since we created it, but it still works.

```lia-code-sample
class HubspotAPI {

 // Function to send lead to Hubspot
 public function sendLead($post) {
 // Default settings
 $baseURL = 'https://forms.hubspot.com/uploads/form/v2/';
 // Portal ID of client
 $portalId = 'xxxxx';

 // Hubspot Form ID (grabbed from URL)
 $hubspot_form = '';
 if (isset($post['hubspot_form'])) {
 $hubspot_form = $post['hubspot_form'];
 } else {
 return 'No endpoint set!';
 }

 // if (!isset($post['email'])) {
 // return 'Important information is missing';
 // }

 $params = '';

 // Loop through all post values and build URL params, example: FirstName=Teun&LastName=Rutten
 foreach($post as $key => $value) {
 if ( ! empty( $value ) ) {
 $name = $key;
 $params = $params . $name . '=' . urlencode($value) . "&";
 }
 }

 $hubspotutk = isset($_COOKIE['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' => $post['url'],
 'pageName' => isset($post['page']) ? $post['page'] : ''
 );
 $hs_context_json = json_encode($hs_context);
 $params = $params . '&hs_context=' . urlencode($hs_context_json);

 // Prepare URL
 $endpoint = $baseURL . $portalId . '/' . $hubspot_form;

 $ch = curl_init();
 curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
 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);
 $response = curl_exec($ch); //Log the response from HubSpot as needed.
 $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //Log the response status code
 curl_close($ch);
 return $response . ' ' . $status_code;
 }
}

```

We created the above class, which can be called in the PHP file where you are sending your form:

```lia-code-sample
$sendHubspot = new HubspotAPI();
$sendHubspot->sendLead($_POST);

```

You have to pass it the URL, page name and the ‘hubspot\_form’ (Form ID) through the post object, which could be achieved by setting those as hidden fields, are setting it through the code.

Important note, if the **name** of your input of your form matches a HubSpot contact property, the value will be stored on the contact
