CMS-General

Add a Javascript file to HubSpot

Last updated: October 8, 2018

In Beta

Applies to:

Marketing Hub
marketing-basic-pro-enterprise
Basic, Professional, Enterprise

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. 

new-file

  • 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. 
  • 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.

attach-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

Was this article helpful?

If you still need help you can get answers from the , or to contact support.