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. It has been built to suit your needs with best practices just like Superhuman.
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. π
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:
- Register an account on the Formbricks platform.
- Customize your PMF survey to suit your preferences.
- Seamlessly integrate Formbricks into your application.
- 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 or take the simpler path by registering an account on the Formbricks Cloud platform. 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:
If everything has proceeded smoothly up to this stage, let's continue to create and customize our PMF survey π
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.
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.
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.
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.
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:
You may get a note in orange that hints you haven't connected with our app yet. It looks like this:
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.
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.
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.
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.
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:
To connect our app with the cloud, we'll have to dive into our code editor π
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:
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:
Having done this, the widget status indicator should have been updated to this:
Also, you should see that your PMF survey has been fetched in your browser's console:
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:
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:
And there you have it, you have successfully implemented your in-app PMF survey.
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 π¨
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. π π
To help us keep this articles coming, don't forget to give us a star on Github. π
Thank you for reading!
Top comments (2)
Wohoo thanks a lot Ola!
Keep the formbricks articles coming. Very well detailed