Skip to content

Scripts Overview

Scripts are JavaScript files that run across your community pages, independent of individual widgets. Use them for analytics, tracking, shared utilities, or any page-level behavior that applies globally instead of to one widget at a time.

How Scripts Work

Each script you declare in the scripts array of extensions_registry.json becomes a <script> tag injected into every matching page of your community. The platform publishes the file from your repository (or loads it from an external URL) and inserts the tag at the location you choose.

Scripts vs Widgets

AspectWidgetScript
ScopeOne component in one page zoneThe whole page, every matching page
PlacementChosen in the No-Code BuilderDeclared via placement field
IsolationShadow DOMRuns directly on the page
ConfigurationPer-instance via No-Code BuilderSame for every page that loads it
Use casesInteractive UI, forms, dashboardsAnalytics, tracking, shared utilities

Widgets exist to give community admins something to place and configure. Scripts exist to run page-level code that doesn't belong to any single widget.

Where Scripts Run

Scripts are injected at one of three locations, controlled by the placement field:

PlacementLocationUse case
head (default)Inside <head>Analytics, early initialization, scripts that need to run before content renders
bodyStartStart of <body>Scripts that need the DOM to start loading but should run early
bodyEndEnd of <body>Non-critical scripts that depend on page content being fully loaded

Repository-Hosted vs External

Each script has a path field. Two shapes are supported:

  • Repository path (e.g. scripts/analytics/script.js) — the file lives in your repository and the platform publishes it.
  • External URL (e.g. https://cdn.example.com/tracker.js) — the tag loads directly from that URL. The platform does not fetch or publish it.

Conditional Loading

By default, a script loads on every page of your community. Use the rules field to load a script only when the current page matches conditions like a specific page type, locale, or authenticated user. See Page Targeting for the full rule language.

Next Steps

Gainsight CC Developer Portal