Using HubSpot Exported Form Code on Wordpress
Posted by Ken Pearce on Mon, Sep 26, 2011 @ 12:33 PM
This article will outline the proper way to install exported form code from HubSpot on Wordpress to avoid getting any spam submission errors. It's easiest to have both your HubSpot portal and your Wordpress site open in separate tabs.
First, create your form in HubSpot by going to Settings > Form Manager > Create New Form. If you're using an existing form you can just hit 'Edit' on the same screen.
Next, hit "Get Form HTML." In the input box you can either put the url of your homepage, such as http://heykenneth.com or a url to a separate thank you page you've already created.

Hit "Next" and you will be presented with the form code to use on your non-HubSpot website. From here the easiest thing to do is copy and paste all of the code into Notepad or TextEdit if you're on a Mac.
Make note of the following lines of code located between the open and close <script> tags:

This script, highlighted above, is what HubSpot uses to check for spam when a form is filled out on your website. Next we will cover moving this chunk of code from the exported form html to the header.php file in your Wordpress site.
Once logged into Wordpress:
- Click on the "Appearance" tab in the left hand side menu
- Select "Editor"
- On the right side of the page there will be a long list of core Wordpress files
- Look for Header.php


If you followed the steps above you should now be looking at your website’s HTML
- Scroll to the bottom of Header.php and look for the close </head> tag
- Paste the chunk HubSpot code right above it
- Make sure to include both the open and close script tags <script> … </script>
- Hit "Update File"

The final steps involving taking the remaing code and placing it into a content area on your Wordpress site.
You can either paste the code into a sidebar text widget or directly inline on a content page. If pasting it inline on a content page make sure to be in "HTML" mode.

If you've completed the steps above, from this point going forward all you will need to do is delete the HubSpot spam check script from your HubSpot exported form code and paste in the html on your Wordpress site as usual.
* Note: Make sure you do not include the script we removed earlier when adding in the form code.