Workspace scripts (also called global scripts) let you add HTML, CSS, or JavaScript code once and apply it to multiple landing pages in the same Instapage workspace. This article explains what workspace scripts are, where to add them, how to choose which pages they apply to, and in which order workspace scripts and page-level scripts load.
This article is for account owners and team members who manage code that must run on many pages, such as tracking codes or consent banners. To add code to a single page only, see Using Custom HTML, Javascript and CSS on Your Page.
What are workspace scripts?
Workspace scripts are code snippets that apply to multiple pages in a workspace at the same time. Workspace scripts are a workspace-level setting, so they only affect the pages in the workspace where you add them. To learn more about settings that affect an account versus settings that affect a workspace, see this guide: https://d.pr/77fOeP.
You can add any HTML, CSS, or JavaScript code that you want to apply to multiple pages at once. Common examples include:
A consent management banner
The Google tag of a Google Analytics property
The Google tag of your Google Tag Manager container (see Adding Google Tag Manager to Instapage)
An HTML FAQ widget
CSS that changes the properties of a specific class of objects
A sticky header code
Tracking scripts from the tracking platforms you use
What you add to workspace scripts depends on your goals for your landing pages. You can apply the workspace scripts to all past and future pages at once, or choose manually which pages they apply to. Both options are explained in the How to choose which pages the workspace scripts apply to section.
How to add, edit, or remove workspace scripts
Workspace scripts are managed in the Assets tab of the workspace. To add, edit, or remove workspace scripts, follow these steps:
In the left-side menu of the Instapage app, click Assets. The Assets menu expands and shows Styles, Forms, Images, Popups, Fonts, and Scripts.
Click Scripts.
Add or edit your code in the code editor. The code editor has three sections: Head, Body, and Footer. You can add JavaScript, HTML, and CSS in all three sections.
Click Apply to save the changes. Make sure you click Apply before you navigate away from the Scripts page, or your changes will not be saved.
The code you add must always use valid syntax: <script></script> tags for JavaScript, <style></style> tags for CSS, and valid HTML syntax.
When the syntax is correct, the code editor changes the colors of the text to help you see the different parts of the code. When the syntax is incorrect, the text stays black. Use this to find missing semicolons, brackets, tags, and similar errors.
How to choose which pages the workspace scripts apply to
Above the code editor, in the Workspace Scripts section, you can choose whether to apply the workspace scripts to all pages at once or to manage them manually for each page. The section shows these options:
A – Enable the script for all pages (radio button)
B – Manage the script manually for each page (radio button)
C – Enable script by default (checkbox, available only when B is selected)
You can select A, B, or B together with C. The table below explains what each option does:
| Option selected | What happens to the workspace scripts | Can you turn the script on or off for a single page? |
|---|---|---|
| A – Enable the script for all pages | The scripts are applied to all past and future pages in the current workspace. | No. The per-page toggle is greyed out. |
| B – Manage the script manually for each page (without C) | The scripts are not applied to any page automatically. | Yes. Turn the script ON for each page where you want it. |
| B + C – Manage the script manually for each page, with Enable script by default checked | The scripts are enabled for all pages, except the pages where the toggle was changed manually before. | Yes. Turn the script OFF for each page where you do not want it. |
How to turn a workspace script on or off for a single page
If you selected option B (with or without C), you can turn the workspace scripts on or off for each landing page. To do this, follow these steps:
Open the Landing Pages tab.
Click the name of the page.
In the page settings panel that opens on the right, click Scripts & Privacy.
Scroll down to the Workspace Scripts area and use the Enable Workspace Scripts toggle to turn the scripts on or off for this page. Below the toggle, the workspace scripts are shown in read-only Head, Body, and Footer tabs.
If you selected option A, Enable the script for all pages, the toggle is greyed out, and you cannot change it for individual pages.
Which scripts load first on a page
On the live URL of a page, the workspace scripts load first. The page-level scripts, added in the page builder or in the page slideout, load after the workspace scripts.
Workspace scripts and page-level scripts work together. If the scripts are written to do so, a page-level script can add to or extend what a workspace script does.