How to install our global embed code (2.0)
Copy the global embed code from the Publish Wizard (Embed Inline, then Install Global Embed Code), paste it once into your site's head or just after the body tag, and click Validate. After that, pop-ups need no extra code and each inline campaign needs only its placement. Can't add a script? Use an iframe instead.
What you can do with the global embed code
| To | Do this |
|---|---|
| Add ShortStack to your site once, for every campaign | Get your code and add it to your platform. |
| Show a campaign inside a page | Install the code, then place the campaign. See How to embed a campaign inline (2.0). |
| Show a campaign as a pop-up | Install the code. Pop-ups need nothing else. See How to embed a campaign as a pop-up (2.0). |
| Check the code is installed | Click Validate in the Publish Wizard. See After installation. |
| Embed on a site that won't accept scripts | Use an iframe. See Can't add a script to your site? |
Before you start
- You install the code once per site. After that, pop-ups need no more changes to your site, and each inline campaign needs only a placement.
- How many sites you can embed on depends on your plan: 1 on Free and Launch, 3 on Build, 5 on Scale and 10 on Max. Each site includes its aliases, such as
wwwand a staging subdomain. See Connected Sites Manager. - You need to be able to edit your site's code or settings, or ask whoever looks after your site.
Get your code
The code comes from the Publish Wizard the first time you embed a campaign on a site.
- In the Campaign Builder, click Publish Campaign.
- Select Embed Inline (or Embed Pop-up) and click Continue.
- Enter the full URL of the page where the campaign will appear, or choose your site from the list, then click Continue.
- Select Install Global Embed Code.
- Copy the code shown, paste it into your site using the steps for your platform below, and publish your site changes.
- Back in the wizard, click Validate to confirm the code is installed. Once it's validated, click Continue to place and publish your campaign.
Add the code to your site
Paste the code once, in the <head> or just after the opening <body> tag, using the steps for your platform. Then publish your site and clear any caches.
WordPress
- Log in to your WordPress Admin Dashboard.
- Install and activate a plugin such as WPCode – Insert Headers & Footers.
- From the plugin's settings, open the Header & Footer code areas.
- Paste your ShortStack embed code into the Header box.
- Save changes, then clear any cache if you're using a caching plugin or CDN.
Shopify
- From the Shopify admin, go to Online Store → Themes.
- Next to your active theme, click Actions → Edit code.
- Open the file layout/theme.liquid.
- Paste your embed code just after the opening
<body>tag. - Click Save. Your code will now load across your store.
Wix
- Go to your site Dashboard → Settings → Custom Code (under the Development & Integrations section).
- Click + Add Custom Code.
- Paste your ShortStack embed code.
- Choose Place Code in: Head.
- Select All Pages.
- Save and Publish your site.
Squarespace
- From the main menu, go to Website → Pages → Custom Code → Code Injection.
- Paste your embed code into the Header box (code added here is injected into the
<head>tag on every page). - Click Save.
Webflow
- Open your Project Settings.
- Navigate to the Custom Code tab.
- Paste your embed code into the Head Code section.
- Save changes.
- Publish your site to push the update live.
BigCommerce
- From the admin, go to Storefront → Script Manager.
- Click Create a Script.
- Set Placement to Header and Location to All Pages.
- Paste your embed code into the script content field.
- Save.
Magento / Adobe Commerce (Magento 2)
- Go to Content → Design → Configuration in the admin panel.
- Edit your active store view.
- Under Other Settings → HTML Head → Scripts and Style Sheets, paste your embed code.
- Click Save Configuration.
- Go to System → Cache Management and Flush Cache.
HubSpot CMS
- In HubSpot, go to Settings → Advanced.
- Find Site header HTML.
- Paste your embed code.
- Save changes.
Duda
- Open your site in the Duda editor.
- Go to More → Settings → Header HTML.
- Paste your embed code into the Header HTML box (this places code in the
<head>of your site). - Publish your site.
Drupal
- Install and enable a module such as Header and Footer Scripts.
- In the configuration screen, find the Header Scripts field.
- Paste your embed code.
- Save configuration.
- Clear your Drupal cache so the code takes effect immediately.
Square/Weebly
- Click Theme in the top menu.
- In the lower left corner, click the Edit HTML / CSS button.
- Look for a file named header.html in the sidebar and click it to open it in the file editor.
- Find the opening
<body>tag and paste our global embed code just after it. - Click Save in the upper-right corner to save the theme.
Other platforms and custom sites
On a developer platform or hosting service, add the code to the layout file every page uses.
Static hosts, such as Netlify and GitHub Pages
- Add the embed code to your global HTML layout file (e.g.,
baseof.htmlin Hugo,_layouts/default.htmlin Jekyll). - Place it in the
<head>or just after the opening<body>tag to ensure it runs on every page.
Vercel, Next.js and React apps
- Add the embed to your global layout file, usually
_document.jsor_app.js. - If you import it into a
.jsfile instead of HTML, remove the<script>and</script>tags, and include only the JavaScript inside.
Custom CMS or frameworks
-
Place the embed code in your main template:
- Rails:
app/views/layouts/application.html.erb - Laravel:
resources/views/layouts/app.blade.php - Django:
templates/base.html - Joomla: edit
index.phpin your active template
- Rails:
-
Place it in the
<head>or just after the opening<body>tag.
Blogger and GoDaddy Website Builder
- Blogger: Go to Theme → Edit HTML, and add just after
<body>. - GoDaddy Website Builder: Use Site-wide Code Injection under Settings, and paste in the Header section.
After installation
- Clear your caches: clear any site, plugin or CDN cache, so the code shows right away.
- Validate: in the Publish Wizard, click Validate. If the code isn't found, ShortStack shows more information to help you fix it.
- Inline campaigns: place each campaign with the Visual Picker Tool, or paste its ShortStack
<div>where you want it to display. See How to embed a campaign inline (2.0). - Pop-ups: no extra steps. Once the code is installed, they work across your site.
Validated, but the campaign still doesn't show? See Troubleshooting embed issues.
Can't add a script to your site?
If your CMS or website builder won't accept a script, you can embed a campaign with a self-contained <iframe> instead. It needs no global embed code, so there's no validation step.
- Click Publish Campaign and select Embed Inline, then click Continue.
- Add your site or choose it from the list. When adding a new site, enter its domain, then select Install on Each Page.
- Click Continue, enter the exact URL of the page where the campaign will appear, and click Publish. The code appears only after you publish.
- Between the two code snippets, check I don't want to use the embed script. Use iframe code instead (iframe height is fixed).
- Copy the iframe code into your page and publish your site.
If something goes wrong
| What you see | What to do |
|---|---|
| Validate says the code isn't found | Check you pasted the whole code, published your site, and cleared any caches. Then click Validate again. |
| The code validates, but the campaign doesn't show | For an inline campaign, check the campaign is placed, with the Visual Picker Tool or its <div>. See Nothing appears where the campaign should be. |
You pasted only the <div>, and nothing shows | The <div> needs a script to load the campaign: the global embed code, or the page embed script shown with the <div>. See Alternative to using the global embed code. |
| The code validates, but the script is blocked | Your site's Content Security Policy may block it. Ask your web team to add *.lndg.page to its script-src directive. |
| The campaign is cut off or leaves a gap on phones | It's probably embedded with an iframe, which has a fixed height. Use the global embed code instead. See Troubleshooting embed issues. |
| You can't add another site | You've used your plan's connected sites. See Connected Sites Manager. |
FAQs
Do I need to do anything extra for mobile?
No. A campaign embedded with the global embed code (or the <div> and script) resizes to fit the screen on its own. If it's cut off or leaves a gap on phones, it's probably embedded with an iframe, which has a fixed height. See Troubleshooting embed issues.
Will replacing my old iframe with the new code affect entries I've already collected?
No. Switching from an iframe to the <div> and script only changes how the campaign is displayed on your page. Your entries stay with the campaign.
How many sites can I embed campaigns on?
It depends on your plan's connected sites: 1 on Free and Launch, 3 on Build, 5 on Scale and 10 on Max. Each connected site includes its aliases, such as www and a staging subdomain, so one site can cover both staging and live. Landing pages, pop-ups and embeds are unlimited on every plan. See pricing for details.
Can I still use the old embed method?
Yes. The legacy method is publishing with an iframe, and it's still available. See Can't add a script to your site? for the steps. An iframe has a fixed height, though, so use the global embed code whenever your site allows it. Once the global code is installed, each new campaign needs only a placement.
How does the global embed code work?
When someone visits your page, the code checks which of your ShortStack campaigns are active, finds the spots on the page you've set for inline campaigns, and loads each campaign into its spot. For pop-ups, it waits for the trigger you chose, such as time on page or scroll depth. Campaigns load in their own frame (an iframe), so your site and the campaign stay separate.
Does it capture any information or track visitors' behavior?
Very little, and it stays on the visitor's device. The code only remembers how many times someone has seen a campaign and when they last saw it, in their own browser. It doesn't track visitors across websites, collect personal information, set marketing cookies or send data to analytics services.
What functionality does the global embed code enable?
The embed code lets you show campaigns inside your webpage, display pop-up campaigns (center, sliding, or notification bars), and control when pop-ups appear based on time, scroll depth, exit intent, or specific page location.
Are there any security implications or concerns?
Campaigns run in their own protected frame, your website's styling stays separate, and the code can't reach sensitive information such as passwords or private form data.
What security headers are being added to the page?
None. The code can add content to your page, but it can't change your site's security settings, which your web server controls. If your site sends a Content Security Policy header, add *.lndg.page to its script-src directive so the embed script can load.
What JavaScript or CSS libraries are being used?
None. The code is self-contained, so it can't conflict with your site's own tools, loads quickly and has fewer security risks.
Related resources
Was this helpful?
Thanks — that helps us decide what to fix next.
Sorry this missed. Tell us what you needed and we'll get you an answer — and fix the page.