💎
Headless Docs
Version 0.2.0
Version 0.2.0
  • Overview
  • Change Log
  • Next.js Steps
    • Requirements
    • Determine Page Methods
      • Route Hashing Method
      • Cookies Method
    • Install Middleware
    • Add Intelligems Provider
    • Read User Context
      • Route Hashing Method
      • Cookies Method
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Gatsby Steps
    • Requirements
    • Add Intelligems Provider
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Pack Digital Steps
    • Requirements
    • Add Intelligems Provider
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Examples
    • Content Testing
  • Reference
    • Middleware Objects
      • IgMiddlewareConfig
      • IgMiddlewareHandler
    • Providers
      • Next.js
      • Gatsby
    • Components
      • Price Components
    • Hooks
      • Price Hooks
      • Track Hooks
      • Experiment Hooks
      • Test Group Hooks
      • Cart & Checkout Hooks
Powered by GitBook
On this page
  1. Examples

Content Testing

Use content testing to show different site content per Test Group.

const SomeComponent = () => {
  const experimentId = '<EXPERIMENT_ID>';
  const testGroup = useIgTestGroup(experimentId);

  const DynamicComponent = useMemo(() => {
    if (testGroup.isReady) {
      if (testGroup.testGroup.name === 'New Group 1') {
        return (
          <div>
            This component only renders if the Test Group is "New Group 1"
          </div>
        );
      } else {
        return (
          <div>
            This component only renders if the Test Groups is the Control Group
          </div>
        );
      }
    } else {
      // Intelligems configuration has not loaded yet, or
      // Intelligems configuration never requested
      return null;
    }
  }, [testGroup]);

  return <div>{DynamicComponent}</div>;
};

PreviousPreview Your SiteNextMiddleware Objects

Last updated 1 year ago