# Add tracking script to form using onFormSubmit Problem

**URL:** <https://community.hubspot.com/t/add-tracking-script-to-form-using-onformsubmit-problem/22677>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [July 9, 2020, 5:21pm UTC](https://community.hubspot.com/t/add-tracking-script-to-form-using-onformsubmit-problem/22677 "2020-07-09T17:21:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rix](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rix/32/98942_2.png) [@rix](https://community.hubspot.com/u/rix)\
**Post date:** [July 9, 2020, 5:21pm UTC](https://community.hubspot.com/t/add-tracking-script-to-form-using-onformsubmit-problem/22677/1 "2020-07-09T17:21:33Z")

</div>

After adding a clients conversion tracking script to a form, the form is no longer rendering on the page. Here is the script on the page:

\<!--[if lte IE 8]\>  
\<script charset=“utf-8” type=“text/javascript” src=“[//js.hsforms.net/forms/v2-legacy.js](https://js.hsforms.net/forms/v2-legacy.js)”\>\</script\>  
\<![endif]--\>  
\<script charset=“utf-8” type=“text/javascript” src=“[//js.hsforms.net/forms/v2.js](https://js.hsforms.net/forms/v2.js)”\>\</script\>  
\<script\>  
hbspt.forms.create({  
portalId: “308538”,  
formId: “1accc070-6f5e-4255-9bd9-0e605a0bcd6f”,  
onFormSubmit: function($form) {  
function gtag\_report\_conversion(url) {  
var callback = function () {  
if (typeof(url) != ‘undefined’) {  
window.location = url;  
}  
};  
gtag(‘event’, ‘conversion’, {  
‘send\_to’: ‘AW-734892296/oj8VCKK2sNMBEIiitt4C’,  
‘event\_callback’: callback  
});  
return false;  
}  
});  
});  
\</script\>

Here is the page the form is on in staging:

[http://www-amarok-com.sandbox.hs-sites.com/contact?hs\_preview=SLGbOBnk-32077702951](http://www-amarok-com.sandbox.hs-sites.com/contact?hs_preview=SLGbOBnk-32077702951)

It looks as though the hbspt.forms.create is not firing

Here is the live page without the conversion code added which is rendering the form ok.

> **[Contact Us | AMAROK Ultimate Perimeter Security](https://amarok.com/contact/)**
>
> Are you experiencing routine theft on your business property? Contact our perimeter security experts to prevent theft on your property.

---

<div class="post-metadata">

**Author:** ![dennisedson1](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson1/32/32521_2.png) [@dennisedson1](https://community.hubspot.com/u/dennisedson1)\
**Post date:** [July 9, 2020, 11:03pm UTC](https://community.hubspot.com/t/add-tracking-script-to-form-using-onformsubmit-problem/22677/2 "2020-07-09T23:03:50Z")

</div>

Hello @rix!,

Looks like you added a couple characters too many. If you remove the ); as you can see in the attached screengrab, you should be good to go!

Just to confirm it was working, I threw it up on a codepen as well. You can see it [here](https://codepen.io/billyoncetoldme/pen/GRodbde)

Post back if you have any other issues 🙂

 ![29100i66A731036EFD4103.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/f/cf080d902c115df381721a85c9cd0a048314a21a.png)

---

<div class="post-metadata">

**Author:** ![rix](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rix/32/98942_2.png) [@rix](https://community.hubspot.com/u/rix)\
**Post date:** [July 10, 2020, 12:03am UTC](https://community.hubspot.com/t/add-tracking-script-to-form-using-onformsubmit-problem/22677/3 "2020-07-10T00:03:53Z")

</div>

There it is! Perfect thanks
