Design Manager

Add a JavaScript file to HubSpot

Last updated: March 4, 2020

In Beta

Applies to:

Marketing Hub  Professional, Enterprise
Legacy Marketing Hub Basic

In your design manager, you can host and edit JavaScript files. Learn how to create a JavaScript file and linking it to a template or domain.

Create a JavaScript file

  • In your HubSpot account, navigate to Marketing > Files and Templates > Design Tools.
  • In the left sidebar menu, click Actions > New file. You may need to click the folder icon folder to expand the menu. 


  • In the dialog box, click JavaScript

  • In the next dialog box, enter a name for your JavaScript file and click Create.

  • Type or paste your JavaScript into the code editor. 
  • If you've enabled ESLint, you can see any JavaScript warnings or errors by clicking to toggle the Show output switch on.

  • In the upper right, click Publish changes to take your changes live.

Attach your JavaScript file to your template

  • In the finder, click the template you want to update.
  • In the inspector, click the Edit tab.
  • In the Linked JavaScript files section, click the Add dropdown menu and select your JavaScript file.


  • In the upper right, click Publish changes to take your changes live.

Include your JavaScript file on all your HubSpot pages

You can include your JavaScript file on all the pages of a HubSpot-hosted domain using the public URL.
  • In the left sidebar menu, select your JavaScript file.
  • Click Actions > Copy public URL.

  • In your HubSpot account, click the settings icon settings in the main navigation bar.
  • In the left sidebar menu, navigate to Website > Pages.
  • Click the Modifying dropdown menu and select the domain to add the JavaScript file to.
  • In the Site footer HTML section, paste the public URL as the value for the script tag’s source. 
<!-- start Main.js Do Not Remove -->
<script src='insert your file's public URL here'></script>
<!---End Main.js-->
  • Click Save