Custom code

How to add code to every page (head and body)

How to add code to every page (head and body)

To add a script, style or tag to every page of a TeleportHQ site, click the Project settings cog at the bottom of the editor's left sidebar, open Custom code, choose Head or Body and paste the code. The code saves itself. Then publish your site: the code runs on your published site, in the preview and in downloaded code, but not on the editor canvas.

Before you start

  • You need permission to change project settings (Owner, Admin or Designer role).
  • Get the full code snippet from the tool you're adding, including its opening and closing tags, for example <script> and </script>.
  • Head or Body? Follow the tool's instructions. As a rule:
    • Head: <meta>, <link> and <style> tags, and scripts the tool says to put in the head (many analytics tools).
    • Body: scripts the tool says to put in the body, such as chat widgets.
  • The settings list the tags you can add here: link, meta, style and script.
  • For fonts, use Project settings → Fonts instead. See How to upload your own fonts.
  • For Google Analytics or Google Tag Manager, use their own fields instead. See How to add Google Analytics or Google Tag Manager.

Steps

  1. In the editor, click the Project settings cog at the bottom of the left sidebar. The Project settings panel opens.
  2. Under Data & code, click Custom code ("Code added to the head and body of every page."). The Custom code settings open next to the panel.
The Data & code group of the TeleportHQ Project settings panel, with Custom code highlighted
  1. Click Head or Body.
  2. Click inside the code box and paste your code. For example, a chat widget in Body:
    <script src="https://widget.example.com/chat.js" async></script>
  3. Wait a moment. The code saves itself as you type: there's no Save button.
The TeleportHQ Custom code settings with the Head and Body buttons above the code box
  1. Close Custom code with the close button at its top right (tooltip Close).
  2. Publish your site. See How to publish your site.

Check that it worked

Open your published site in a new browser tab. The tool should work there, for example the chat bubble appears. To confirm the code is on the page, right-click the page, choose View page source, and search for part of your snippet. You can also test before publishing: the editor's preview includes your custom code. See How to preview your site before publishing.

Troubleshooting

The code doesn't work in the editor That's expected. TeleportHQ doesn't run custom code on the editor canvas: "You will not be able to interact with the 3rd party code while editing your project in the playground, this will only work on your published websites." Test it in the preview or on the published site.

The code doesn't work on my live site

  • Publish again. Saving the code doesn't update the live site by itself.
  • Check you pasted the whole snippet, including opening and closing tags.
  • Check the tag type: this box is meant for link, meta, style and script tags. To place visible HTML (a table, a form, an iframe) in one spot, use a Code Embed element instead.

My site layout broke after adding code The settings warn: "WARNING: Invalid code added here might break your website." Delete the code you added, publish again, and check the snippet with the tool's provider.

The browser console shows "A custom code script on this page failed:" One of your scripts throws an error. TeleportHQ catches it and writes it to the browser console as a warning, with the error after it. Read the error, then fix or remove that script and publish again.

Change custom code from the dashboard

The project's settings page on the dashboard has the same code boxes, next to the Google Analytics and Tag Manager fields. There, changes only save when you click Save Changes.

  1. On the dashboard, click ⋯ on the project's card, then Project Settings.
  2. In the menu on the left, click Custom Code.
  3. Scroll to Custom code, click Head or Body, and paste your code.
  4. Click Save Changes. The message "The changes have been saved" appears.

Good to know

Share

Related Articles

How to add your own HTML or JavaScript with Code Embed

In TeleportHQ, you add your own HTML, CSS or JavaScript to one spot on a page by dragging or clicking the Code Embed element in Elements → Primitives → Media, pasting the code into the Code Embed (HTML+CSS+JS) window and clicking Save.

How to add Google Analytics or Google Tag Manager

To add Google Analytics 4 to a TeleportHQ site, open the project's Project Settings page from its card on the dashboard, click Custom Code, paste your measurement ID (starting with G-) into Analytics or your container ID (starting with GTM-) into Tag Manager, click Save Changes and publish.

How to add a tracking pixel (Meta, TikTok, LinkedIn)

To add a Meta Pixel, TikTok Pixel, LinkedIn Insight Tag or any other tracking script to a TeleportHQ site, copy the code from the ad platform, open Project settings (the cog at the bottom of the left sidebar) → Custom code, paste it under Head, and publish; the code saves itself.

A tour of Project settings: everything you can set for your project

In the TeleportHQ editor, click the Project settings cog at the bottom of the left sidebar to open one panel with every project setting, grouped under Site, Appearance, Data & code, Editor, AI, Credentials and Integrations; click an entry to open it in a drawer beside the panel, and switch features such as the store or the blog on in the Plugins tab.

How to import HTML and CSS code

In the TeleportHQ editor, click Import HTML / CSS / JS in the bottom toolbar (or paste HTML onto the canvas), paste plain HTML with its CSS in the HTML Import window and click Save; TeleportHQ turns it into editable elements and classes.

How to publish your site

In TeleportHQ, click Publish at the top right of the editor, keep Production selected, and click Publish to Production; a progress bar beside the button shows each step, and after a few minutes your site is live on a free TeleportHQ address that you can share.