Install Platforms

Documents / Installation

Install by platform

A platform is the kind of website you run — plain HTML, WordPress, Shopify, and so on. CROForge shows platform buttons on the Smart Code tab so you can copy a snippet that matches how that stack usually injects scripts. Today only HTML and WordPress are fully ready in the UI. Other keys exist for later guides.

Always register the site under Configurations → Websites and Apps first, then copy the snippet from that website’s Code tab — not from Settings → Installation.

Words used on this page

WordEveryday meaningMeaning in CROForge
PlatformThe CMS or framework that builds the siteA Smart Code UI key such as html, wordpress, nextjs, shopify
Smart CodeA small program snippet to pasteThe install code for that platform, always loading the same init.js
SnippetA short piece of code to copyHTML for the HTML tab; PHP for the WordPress tab
init.jsThe file that starts experimentshttps://app.croforge.com/{workspaceId}/init.js?ver=1.0.0 with id cro-forge-experiments-js
wp_headWordPress’s hook that prints tags in <head>CROForge’s PHP helper uses add_action('wp_head', …, 0) so the script prints as early as possible
Priority 0Go first in a queueWordPress runs this callback before later wp_head callbacks
functions.phpA theme file for extra PHPWhere the product tells you to paste the WordPress helper: /wp-content/themes/<your-theme>/functions.php
DomainThe website address hostMust be registered on the website record so install and verify stay tied to that host
AllowlistAn approved listSmart Code only runs when the live hostname is on the workspace domain list
HeadThe top of the HTML documentRecommended paste location on HTML and via headers/footers plugins
Async vs SyncWait or not wait while a script loadsHTML Smart Code defaults to Async; start there unless engineers choose Sync
FlickerA brief flash of the original pageEarly <head> / priority 0 injection helps variations apply before visitors notice the original
SPAURL changes without a full reloadTypical of Next.js App Router; confirm targeting on client navigations

Screenshot

Use this screenshot filename when you add a capture: install-platforms.png in docs/assets/placeholders/. Do not embed an image in this file.


Supported in the Smart Code UI today

PlatformKeySnippet in the product
HTMLhtmlYes — primary. Full snippet plus copy.
WordPresswordpressYes — PHP wp_head helper.

Other keys exist in SMART_CODE_PLATFORMS but platform buttons and guides may be hidden or incomplete:

LabelKeyStatus
Next.jsnextjsKey exists; guide not fully selectable
DrupaldrupalKey exists; guide not fully selectable
ShopifyshopifyKey exists; guide not fully selectable
WixwixKey exists; guide not fully selectable
PrestaShopprestashopKey exists; guide not fully selectable
JoomlajoomlaKey exists; guide not fully selectable

Until those guides ship, use the HTML snippet (or ask engineering). The website platform enum used when registering a property is WEBSITE_PLATFORM.WEB = 'web' — that is separate from the Smart Code platform buttons.

WordPress

On WordPress, the product gives a PHP helper instead of raw HTML. Everyday meaning: WordPress will print the script while it is building <head>. CROForge uses priority 0 so the script is printed as early as that hook allows.

Product-provided pattern (conceptually — the Code tab already fills in your workspace id):

function add_high_priority_script() {
    echo '<script src="https://app.croforge.com/{workspaceId}/init.js?ver=1.0.0" id="cro-forge-experiments-js"></script>';
}
add_action('wp_head', 'add_high_priority_script', 0);

Steps in the product UI

  1. Copy the generated SmartCode from the WordPress platform card.
  2. Paste it in /wp-content/themes/<your-theme>/functions.php.
  3. Verify the installed Smart Code (see Verify installation).

Alternatively, paste the HTML snippet via a headers/footers plugin into <head>. Keep the same init.js URL and script id.

Child themes: prefer the child theme’s functions.php so a parent-theme update does not wipe the snippet. Avoid adding the helper twice (theme plus plugin), or the script can load twice.

Next.js (App Router) — engineer sketch

Until a first-class Next.js tab is enabled, inject the same script in the root layout. Prefer your team’s approved third-party script pattern (for example next/script with a strategy your performance budget allows). The sketch below is illustrative only.

// app/layout.tsx — illustrative
export default function RootLayout({ children }) {
  return (
    <html>
      <head>
        <link rel="preconnect" href="https://app.croforge.com" />
        <script
          src={`https://app.croforge.com/${process.env.NEXT_PUBLIC_CROFORGE_WORKSPACE_ID}/init.js?ver=1.0.0`}
          id="cro-forge-experiments-js"
        />
      </head>
      <body>{children}</body>
    </html>
  );
}

Next.js App Router sites are often SPAs for in-app navigations. Confirm with engineering how URL targeting and page_view behave on client-side route changes.

Register the property

Always add the site under Configurations → Websites and Apps so install and verify stay tied to a domain. Copying a snippet without registering the hostname can still load init.js, but the domain allowlist will reject the host and campaigns will not run.

Related reading