Content Testing

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

const SomeComponent = () => {
  const experienceId = '<EXPERIENCE_ID>';
  const variation = useIgVariation(experienceId);

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

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

Last updated