Skip to content

Page Targeting

Condition rules control which pages your scripts and stylesheets load on. Each rule matches against a context object that the platform builds automatically for each page request.

When multiple rules are specified, all must match (AND logic) for the asset to be included. Assets without rules (or with an empty array) load on every page.

Rule Structure

FieldTypeRequiredDescription
fieldstringYesThe context field to match against. One of: page, pageType, slug, locale, authenticated.
operatorstringYesComparison operator: eq, neq, in, not_in.
valuestring or arrayYesValue(s) to compare. Use a string with eq/neq, an array with in/not_in.

Operators

OperatorDescription
eqField equals value
neqField does not equal value
inField matches one of the values (array)
not_inField does not match any of the values (array)

Context Fields

The context object is built by the platform for each page request. Not all fields are present on every page — rules targeting an absent field will not match.

page

The internal page identifier within the Customer Community. Only present on customizable and overview pages.

ValueCustomer Community Page
homepageHomepage / Hub homepage
communityCommunity overview
ideationIdeation overview
productUpdatesProduct updates overview
eventOverviewEvents overview
knowledgeBaseKnowledge base overview
category/{id}Specific category page
customPage/{id}Specific custom page
educationHomeEducation home
educationDashboardEducation dashboard
educationCatalogEducation catalog
educationLearningPathsEducation learning paths
educationTrainingEventsEducation training events

Page IDs with dynamic segments

For category and customPage, the page field always includes the ID suffix (e.g., category/123, customPage/456). To match all categories or custom pages regardless of ID, use the pageType field instead.

pageType

Only present for category and customPage pages in the Customer Community. Contains the page name without the ID suffix — useful for matching all pages of a given type.

ValueMatches
categoryAll category pages
customPageAll custom pages

slug

Only present on custom pages in the Customer Community. Contains the URL slug of the custom page.

Example values: getting-started, faq, release-notes

locale

The current Customer Community language in BCP 47 format.

Example values: en-US, nl-NL, de-DE, fr-FR, es-ES, pt-BR, ja-JP

authenticated

Whether the current user is logged in to the Customer Community.

ValueDescription
"true"User is authenticated
"false"User is a guest

Examples

Load stylesheet only on the homepage

json
{
  "name": "homepage-styles",
  "path": "stylesheets/homepage/style.css",
  "rules": [{ "field": "page", "operator": "eq", "value": "homepage" }]
}

Load script on ideation and product updates pages

json
{
  "name": "feedback-tracker",
  "path": "scripts/feedback/script.js",
  "rules": [
    { "field": "page", "operator": "in", "value": ["ideation", "productUpdates"] }
  ]
}

Load script only for authenticated users

json
{
  "name": "user-analytics",
  "path": "scripts/analytics/script.js",
  "rules": [{ "field": "authenticated", "operator": "eq", "value": "true" }]
}

Load stylesheet for Dutch locale on the knowledge base

Multiple rules — all must match (AND logic):

json
{
  "name": "kb-nl-styles",
  "path": "stylesheets/kb-nl/style.css",
  "rules": [
    { "field": "page", "operator": "eq", "value": "knowledgeBase" },
    { "field": "locale", "operator": "eq", "value": "nl-NL" }
  ]
}

Exclude script from education pages

json
{
  "name": "non-education-script",
  "path": "scripts/main/script.js",
  "rules": [
    {
      "field": "page",
      "operator": "not_in",
      "value": [
        "educationHome",
        "educationDashboard",
        "educationCatalog",
        "educationLearningPaths",
        "educationTrainingEvents"
      ]
    }
  ]
}

Load stylesheet on a specific category page

json
{
  "name": "category-123-styles",
  "path": "stylesheets/category-123/style.css",
  "rules": [{ "field": "page", "operator": "eq", "value": "category/123" }]
}

Load stylesheet on all category pages

Use pageType to match regardless of the specific category ID:

json
{
  "name": "all-categories-styles",
  "path": "stylesheets/categories/style.css",
  "rules": [{ "field": "pageType", "operator": "eq", "value": "category" }]
}

Load script on a specific custom page by slug

json
{
  "name": "faq-script",
  "path": "scripts/faq/script.js",
  "rules": [{ "field": "slug", "operator": "eq", "value": "faq" }]
}

Load stylesheet on multiple custom pages by slug

json
{
  "name": "onboarding-styles",
  "path": "stylesheets/onboarding/style.css",
  "rules": [
    {
      "field": "slug",
      "operator": "in",
      "value": ["getting-started", "faq", "release-notes"]
    }
  ]
}

Load script on all custom pages

json
{
  "name": "all-custom-pages-script",
  "path": "scripts/custom-pages/script.js",
  "rules": [{ "field": "pageType", "operator": "eq", "value": "customPage" }]
}

No rules — load everywhere

Assets without a rules array (or with an empty array) load on every page:

json
{
  "name": "global-styles",
  "path": "stylesheets/global/style.css"
}

Next Steps

Gainsight CC Developer Portal