# Guide

This guide builds on the SDK quickstart and analytics guide and shows you how to:

* Create custom object types to model your landing page configuration
* Create flags that use those custom object types
* Access those flags in your code
* Set up a multivariate AI loop to optimize your landing page

## Prerequisites

* [Set up Hypertune](https://docs.hypertune.com/getting-started/set-up-hypertune)
* [Analytics guide](https://docs.hypertune.com/analytics/guide)

## Create custom object types to model your landing page configuration

Go to the **Schema** view in the dashboard. Click the **+** button in the top-right of the sidebar. Select **Object**, enter a name, and click **Create**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FVl8QF0Xqkj03S4PBRrmB%2Flocalhost_3000_projects_6715_main_draft_schema_setup%3D0.png?alt=media&#x26;token=bfc67c01-888d-4b45-98b5-6cfc0d8bc693" alt=""><figcaption></figcaption></figure>

By default, the new object type has no fields.

Click **+ Add** to add a new field. Enter a name, and select **New object type** from the dropdown.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2F0A2jhClHaX9OxaNmVOaS%2Flocalhost_3000_projects_6715_main_draft_schema_setup%3D0%26selected_schema_type%3D%257B%2522type%2522%253A%2522object%2522%252C%2522name%2522%253A%2522LandingPage%2522%252C%2522selectedChildName%2522%253Anull%252C%2522count%2522%253A1%257D.png?alt=media&#x26;token=ad8e465a-f383-4726-acfa-33d098401f82" alt=""><figcaption></figcaption></figure>

Enter a name for the new type and click **Create**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FQq3tuaqpGpMeAvBbNnWh%2Flocalhost_3000_projects_6715_main_draft_schema_setup%3D0%26selected_schema_type%3D%257B%2522type%2522%253A%2522object%2522%252C%2522name%2522%253A%2522LandingPage%2522%252C%2522selectedChildName%2522%253Anull%252C%2522count%2522%253A1%257D%20(2).png?alt=media&#x26;token=2f2cf823-b584-4e6d-b198-acadfbface24" alt=""><figcaption></figcaption></figure>

Click **+ Add** to add a new field to it. Enter a name, set its type, and click **Create**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2F1GBXSi1axNebhQApiNgk%2Flocalhost_3000_projects_6715_main_draft_schema_setup%3D0%26selected_schema_type%3D%257B%2522type%2522%253A%2522object%2522%252C%2522name%2522%253A%2522LandingPage%2522%252C%2522selectedChildName%2522%253Anull%252C%2522count%2522%253A1%257D%20(3).png?alt=media&#x26;token=059829d2-e6f2-4d3a-a5ef-e5034c910dc8" alt=""><figcaption></figcaption></figure>

Repeat for each field you want to add. You can switch to the code view to make this easier. Then, click **Save**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FWyfnA8ud7FhH8G6Vdsfb%2Flocalhost_3000_projects_6715_main_draft_schema_setup%3D0%26selected_schema_type%3D%257B%2522type%2522%253A%2522object%2522%252C%2522name%2522%253A%2522LandingPage%2522%252C%2522selectedChildName%2522%253Anull%252C%2522count%2522%253A1%257D%20(4).png?alt=media&#x26;token=2c107df1-2ebe-4535-a202-433cc6c10a9d" alt=""><figcaption></figcaption></figure>

```graphql
type LandingPage {
  layout: LandingPageLayout!
  hero: Hero!
  ctaButton: CTAButton!
  benefits: [Benefit!]!
}

type Hero {
  headline: String!
  subheadline: String!
  imageSrc: String!
}

type CTAButton {
  buttonSize: ButtonSize!
  text: String!
  color: String!
}

enum ButtonSize {
  small,
  medium,
  large
}

type Benefit {
  icon: String!
  title: String!
  description: String!
}

enum LandingPageLayout {
  default,
  split,
  grid
}
```

## Create flags for your landing page configuration

Go to the **Flags** view in the dashboard. Click the **+** button in the top-right of the sidebar and select **Flag**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2F4EdoMg0rzR8rH9ZWnPBL%2Flocalhost_3000_projects_6715_main_draft_schema_setup%3D0%26selected_schema_type%3D%257B%2522type%2522%253A%2522object%2522%252C%2522name%2522%253A%2522LandingPage%2522%252C%2522selectedChildName%2522%253Anull%252C%2522count%2522%253A1%257D%20(5).png?alt=media&#x26;token=64f62dce-2e64-4a6d-ab6a-ef90d3a71e8c" alt=""><figcaption></figcaption></figure>

Enter a name, set its type to the one you created earlier, and click **Create**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FyEs2OSorqeGgDec08TYN%2Flocalhost_3000_projects_6715_main_draft_schema_setup%3D0%26selected_schema_type%3D%257B%2522type%2522%253A%2522object%2522%252C%2522name%2522%253A%2522LandingPage%2522%252C%2522selectedChildName%2522%253Anull%252C%2522count%2522%253A1%257D%20(6).png?alt=media&#x26;token=f7e31a4d-8167-45aa-8eea-08af7e0da52d" alt=""><figcaption></figcaption></figure>

Enter the initial configuration, then click **Save**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FlBUQ4PZ6ldCjs0Txot2L%2Flocalhost_3000_projects_6715_main_draft_schema_setup%3D0%26selected_schema_type%3D%257B%2522type%2522%253A%2522object%2522%252C%2522name%2522%253A%2522LandingPage%2522%252C%2522selectedChildName%2522%253Anull%252C%2522count%2522%253A1%257D%20(8).png?alt=media&#x26;token=e7db9675-8b3b-4c13-857f-000b4eb16252" alt=""><figcaption></figcaption></figure>

## Access flags to retrieve landing page configuration

Regenerate the client:

{% tabs %}
{% tab title="npm" %}

```bash
npx hypertune
```

{% endtab %}

{% tab title="yarn" %}

```bash
yarn hypertune
```

{% endtab %}

{% tab title="pnpm" %}

```bash
pnpm hypertune
```

{% endtab %}
{% endtabs %}

Then use the generated methods for your flags to get the landing page configuration and log your conversion events:

{% code title="app/components/LandingPage.tsx" %}

```typescript
'use client'

import Benefits from './Benefits'
import CTAButton from './CTAButton'
import Hero from './Hero'
import LandingPageContainer from './LandingPageContainer'
import { useHypertune } from '@/generated/hypertune.react'

export default function LandingPage() {
  const hypertune = useHypertune()

  const landingPage = hypertune.landingPage()

  return (
    <LandingPageContainer
      layout={landingPage.layout({ fallback: 'default' })}
    >
      <Hero hero={landingPage.hero()} />
      <CTAButton
        ctaButton={landingPage.ctaButton()}
        onSignUp={(method) => {
          hypertune.signUp({ args: { properties: { method } } })
        }}
      />
      <Benefits benefits={landingPage.benefits()} />
    </LandingPageContainer>
  )
}
```

{% endcode %}

## Update your landing page configuration

Go to the **Flags** view in the dashboard, expand the top-level flag with your landing page configuration in the left sidebar, and select the nested flag that you want to configure.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FQDnbywdIxIDDVb5jNILs%2Flocalhost_3000_projects_6715_main_draft_schema_setup%3D0%26selected_schema_type%3D%257B%2522type%2522%253A%2522object%2522%252C%2522name%2522%253A%2522LandingPage%2522%252C%2522selectedChildName%2522%253Anull%252C%2522count%2522%253A1%257D%20(10).png?alt=media&#x26;token=b79e734a-c552-470b-b003-2e0ef08e0e7b" alt=""><figcaption></figcaption></figure>

Make your changes, then open the **Diff** view to review them. Click **Save**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FuO0sVHhulgfyjlNPZAzH%2Flocalhost_3000_projects_6715_main_draft_schema_setup%3D0%26selected_schema_type%3D%257B%2522type%2522%253A%2522object%2522%252C%2522name%2522%253A%2522LandingPage%2522%252C%2522selectedChildName%2522%253Anull%252C%2522count%2522%253A1%257D%20(11).png?alt=media&#x26;token=7f02274c-c6c8-4c9b-9d81-d205264c7924" alt=""><figcaption></figcaption></figure>

## Set up a multivariate AI loop to optimize your landing page

Go to the **Flags** view in the dashboard and select the first flag that you want to optimize.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FbgUXUpipvMQcwiZ4EpGX%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Elayout.png?alt=media&#x26;token=ccd6748e-167e-4f49-8b91-16989072ebbf" alt=""><figcaption></figcaption></figure>

Click **+ Experiment**, and select **New experiment** from the dropdown.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2F1l8sDtKswL0vxOYi6JZx%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Elayout%20(1).png?alt=media&#x26;token=8110a573-121e-4a58-851b-858a79fd8b79" alt=""><figcaption></figcaption></figure>

Select **AI loop** as the experiment type, enter a name, set the goal event type that you want to optimize for, and click **Create**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FBUfu6B7ZPR8Klmebms43%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Elayout%20(2).png?alt=media&#x26;token=fb2f8ef7-d4b3-4609-b53e-e3866d17332c" alt=""><figcaption></figcaption></figure>

An experiment dimension is automatically created and named after the selected flag. Click **Insert**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FPnOEuD62WVJvvQ0jDIYl%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Elayout%20(3).png?alt=media&#x26;token=6a762c4e-4623-4c11-88e0-ed90cb1f2b32" alt=""><figcaption></figcaption></figure>

By default, the dimension has two arms called Variant 1 and Variant 2. Click **+ Add variant** to add another. Set the variants to the values you want to test.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FpYlGKS47chaTCLq1DM6m%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Elayout%26selected_split%3DGb1I0ep4brVRh0wt_LIOa%20(4).png?alt=media&#x26;token=add57ac3-84d1-46af-a2bb-3fe058d979d2" alt=""><figcaption></figcaption></figure>

To delete an arm and its variant, select **Delete variant** from the options (**⋯**) button.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FeG5X6pABrRUSr67XmSiX%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Elayout%26selected_split%3DGb1I0ep4brVRh0wt_LIOa%20(5).png?alt=media&#x26;token=f08bb029-83bb-469a-a295-f0dd154faa8a" alt=""><figcaption></figcaption></figure>

Select the next flag that you want to optimize.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FvzrwWCcFF9vjeK7AxkVV%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Ehero%253Eheadline%26selected_split%3DqGYkeCkAmqfnQ9-cAELsv.png?alt=media&#x26;token=233288e9-819d-404c-95f7-9383fb9efa1a" alt=""><figcaption></figcaption></figure>

Click **+ Experiment**, select the AI loop you created earlier from the Experiment dropdown. Then select **New dimension** from the Dimension dropdown.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FP2YMwmiWCIpId4lSe6Z8%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Ehero%253Eheadline%26selected_split%3DqGYkeCkAmqfnQ9-cAELsv%20(1).png?alt=media&#x26;token=aaf33041-c033-4319-95d5-5e6b11c338ca" alt=""><figcaption></figcaption></figure>

Enter a name for the dimension and set its number of arms. By default, it's named after the selected flag. Click **Create**, then click **Insert**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FdR9tu5USrtHRJ8X6U126%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Ehero%253Eheadline%26selected_split%3DqGYkeCkAmqfnQ9-cAELsv%20(3).png?alt=media&#x26;token=b439a5a3-352e-4d5e-a1ef-52cb07175fbf" alt=""><figcaption></figcaption></figure>

Set the variants to the values you want to test.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FIotZdqGqKIaDz5VdWiIx%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Ehero%253Eheadline%26selected_split%3DqGYkeCkAmqfnQ9-cAELsv%20(4).png?alt=media&#x26;token=0b976a0b-fd5d-4379-bdc1-6d39d71946a6" alt=""><figcaption></figcaption></figure>

Repeat these steps for each flag you want to optimize, using the same AI loop in each one.

If you go to the **Experiments** view and select the AI loop, you can see all the dimensions you created.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FWQQWVmeAKHGhgXaLchfU%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Ehero%253Eheadline%26selected_split%3DqGYkeCkAmqfnQ9-cAELsv%20(5).png?alt=media&#x26;token=2d38a3f6-6bbf-4e5a-9e33-d68f23319807" alt=""><figcaption></figcaption></figure>

Click **View changes** to see the changes you made, then click **Save**.

<figure><img src="https://2048905609-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWa3rQLiu4JZhBRkiyoKz%2Fuploads%2FUEe9iQVNZrKWkbEWnNcK%2Flocalhost_3000_projects_6715_main_draft_logic_setup%3D0%26selected_field_path%3Droot%253ElandingPage%253Ehero%253Eheadline%26selected_split%3DqGYkeCkAmqfnQ9-cAELsv%20(6).png?alt=media&#x26;token=afcdc123-eee9-41ee-9466-b1c9a89bf2d3" alt=""><figcaption></figcaption></figure>

Now Hypertune will automatically learn the best combination of variants for each visitor segment to maximize your goal.

## Next steps

* Build an [impact analysis](https://docs.hypertune.com/concepts/impact-analyses) or [funnel](https://docs.hypertune.com/concepts/funnels) to view the performance of each variant or combination of variants.
* Add new dimensions to the AI loop.
* Add new variants to each dimension and remove poorly performing variants.
