📊🔍Measure Your Product-Market Fit With Formbricks' In-App Product-Market Fit Survey 📏📈
Tags: opensource, webdev, product
Published: 2023-10-13 17:55:51

By gauging your startup's product-market fit (PMF), you can determine whether your venture has successfully created a product that resonates with users' preferences and needs.

## TL;DR

In this tutorial, you'll learn how to integrate an in-app PMF survey in your `Next.js` application with [Formbricks](https://formbricks.com). It has been built to suit your needs with best practices just like [Superhuman.](https://review.firstround.com/how-superhuman-built-an-engine-to-find-product-market-fit)


![Time to learn GIF](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3btdr1edpgid6d8c59ni.gif)

## Formbricks: The Only Open-Source Solution For In-App PMF Surveys 

`Formbricks` is an open-source survey software that helps businesses create and send in-app PMF surveys. Formbricks is easy to use and integrates with any web, mobile, or desktop application. Support us by [giving us a star.](https://github.com/formbricks/formbricks) :wink:

Now, before we delve into integrating our PMF survey into our application, let's first create a template for how our survey should appear in our app. We will create this template within the Formbricks cloud platform. 

Here's a brief about the steps we'll cover moving forward:

1. Register an account on the Formbricks platform.
2. Customize your PMF survey to suit your preferences.
3. Seamlessly integrate Formbricks into your application.
4. Implement your in-app PMF survey.


## 1. Create an account on the Formbricks platform - It's free

Formbricks offers you the choice to either [self-host](https://formbricks.com/docs/self-hosting/deployment) or take the simpler path by registering an account on the [Formbricks Cloud platform.](https://app.formbricks.com/auth/login) For this tutorial will opt for the cloud platform. 

Once you have completed the signup and the onboarding procedures, you will be navigated to your dashboard.

Your dashboard should look like this:

![Formbricks dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/li1jossxnze9ckamcaqe.png)

If everything has proceeded smoothly up to this stage, let's continue to create and customize our PMF survey :rocket:

## 2. How to create and customize your PMF survey 

Within the "For you" feed, you may not come across the PMF survey card among the available templates. In such cases, simply click the "Product Experience" filter button, where you'll discover the PMF survey featuring two distinct templates: one resembling the superhuman template and the other being rather short.

Choose the one that aligns best with your requirements. However, for the sake of this article, I'll opt for the superhuman template.

![Product experience description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6g5dolt5iolmrou8akln.png)

However, on selecting the one with the superhuman template, you'll be navigated to a page that contains six different question cards (you can choose to add more if you like), and a Thank you card which will be displayed at the end of the survey.

![Question cards image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dljn3712hv5x1wvscw3n.png)

You can also choose to edit each of the questions if you like by clicking on whichever question card you want to edit. It's worth noting that you changes is reflected in the preview real-time.

As an example, in the second question card, you can choose the next question to be displayed based on which answer was submitted with the logic jumps.

![Logic jump image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pra42fldzz8m1y7oh9yu.png)

In the above image, I have modified my logic to skip to the fourth question card if the "Not at all disappointed" option was selected in the survey instead of normally navigating to the third question. 


![illustration for logic jump](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a1i39r876o7dmelqgn6h.gif)

Once you've completed modifying your questions, navigate to the Settings tab, located right next to the Questions tab. In this section, you can configure your survey according to your preferences.

For the "How to Ask" segment, select the web app choice, since our intention is to integrate it into a web application:

![Web app illustration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j8n84ekx7ewoguzm4nig.png)

You may get a note in orange that hints you haven't connected with our app yet. It looks like this:

![Orange note image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fpxvfzzwhd5afj5ypeps.png)

> I didn't encounter this notification because I had previously connected Formbricks to an application. However, no need to worry! I'll guide you through overcoming this issue in a subsequent section.

Now, moving on to the Survey Trigger section, this is where you'll configure how you'd like your survey to be triggered in your app.

![Survey trigger illustration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o5pv2prkyk0cj9eeh5ad.png)

You can select however you want to trigger your survey in your app when you click the select field.

Perhaps you want to trigger the survey when a user visits a particular URL, this option isn't available in the dropdown. Instead click the "Add Action" option, this will pop-up a modal.

![Survey trigger modal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t6tumd6epnrkssk4jfag.png)

In the above dropdown, I have filled up the required fields to achieve our aim to trigger the survey when a user visits a particular URL. 

Regarding the URL for displaying the survey within our app, I've configured the condition to trigger when the browser's URL contains `https://localhost:3000/dashboard`. This is based on the fact that I'll be using my development server, which initiates on `localhost:3000`.

However, feel free to select any URL of your preference. Just keep in mind that using an invalid URL will result in an error message stating "your survey will not be shown."

When you are done, click the `Track Action` button, the action should now be available in the dropdown. Click the dropdown again to select it. 

![Visit dashboard present](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1gmknl4vn79qzj3wa8du.png)

Once you hit the publish button at the top right corner, you will be navigated to your PMF survey dashboard. Here, you'll be notified that you have not connected Formbricks to your app.

![PMF survey dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ka5x8gzz2jj8lzhnuplp.png)

Hit the connect button, this will direct you to the Setup checklist page.

## 3. Setup Checklist: Integrate Formbricks Widget Into Your Application

Since we haven't connected our application to Formbricks Cloud, the widget status indicator will display on your screen like this:


![Setup checklist status](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xuinz8kcxxo94541bvdx.png)_

To connect our app with the cloud, we'll have to dive into our code editor :rocket:

> To streamline this section, I'll assume that your Next.js application is already up and running, allowing us to get straight to the specifics.

To start, install the Formbricks package into our app with the following command:

```
npm install @formbricks/js --save
```

Next, navigate to the `_app.js` file and paste the following code in it:

```jsx
import formbricks from "@formbricks/js";
import { useEffect } from "react";
import { useRouter } from "next/router";

if (typeof window !== "undefined") {
  formbricks.init({
    environmentId: "<your environment id>" ,
    apiHost: "https://app.formbricks.com", 
    debug: true,
  });
}

export default function App({ Component, pageProps }) {
  const router = useRouter();

  useEffect(() => {
    // Connect next.js router to Formbricks
    const handleRouteChange = formbricks?.registerRouteChange;
    router.events.on("routeChangeComplete", handleRouteChange);

    return () => {
      router.events.off("routeChangeComplete", handleRouteChange);
    };
  }, []);

  return <Component {...pageProps} />
}
```

The `environmentId` property has been intentionally omitted in the `if` statement. In actual practice, this value is private and unique to each user. You can retrieve your `environmentId` from **Step 2** of the setup checklist page. Copy and paste the value into the appropriate variable as seen in the image below:


![Set up checklist image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cs67ztwongdmge1jdzed.png)

Having done this, the widget status indicator should have been updated to this:


![Widget status indicator](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tuj177tas8mdjany1ela.png)

Also, you should see that your PMF survey has been fetched in your browser's console:


![Image of the console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/beelhm9vmmtb7k2zqkuf.png)

If everything works well to this point, let's go ahead to trigger the PMF survey in our app.

## 4. Trigger Your In-app PMF Survey 

I'll navigate to the `dashboard` page from my app's index page. Hence, I'll implement a link to the `dashboard` page in my index page as seen below:

```jsx
import Head from "next/head";
import Link from "next/link";

export default function Home() {
  return (
    <>
      <Head>
        <title>Formbricks PMF Survey</title>
        <meta name="description" content="Generated by create next app" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="icon" href="/favicon.ico" />
      </Head>
      <main>
        {/* link to dashboard */}
        <Link href="/dashboard">Nav To Dashboard</Link> 
      </main>
    </>
  );
}
```

When I click on the `link`, the page navigates to the dashboard and triggers the survey according to how we implemented the trigger on the Formbricks platform:


![Illustration of survey trigger](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wm8ung4jd17v9erjfgbl.gif)

And there you have it, you have successfully implemented your in-app PMF survey.


![Happy gif](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ed9dqwtw97zl2iw9cep.gif)

If you desire a more personalized survey, maybe to harmonize with the colors in your UI, we offer a solution for this in the "Look and Feel" section of the settings page. Feel free to dive in and tailor the survey to your liking :art: 

## Conclusion

So far, you learned how to:

- connect Formbricks Cloud to your app
- create a PMF with the best template possible (superhuman) 
- utilize Formbricks to seamlessly integrate an in-app PMF survey 
- Customize your survey to your taste

With this solution, you are just on the right track to measure your PMF in no time. :rocket: :punch: 

To help us keep this articles coming, don't forget to give us a star on [Github](https://github.com/formbricks/formbricks). :wink:

Thank you for reading!