<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: PostHog</title>
    <description>The latest articles on Forem by PostHog (@posthog).</description>
    <link>https://forem.com/posthog</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F4791%2Ff7b865ed-9072-4cc0-9c62-6eaba3e943c4.png</url>
      <title>Forem: PostHog</title>
      <link>https://forem.com/posthog</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/posthog"/>
    <language>en</language>
    <item>
      <title>Building and measuring a sign up funnel with Supabase, Next.js, and PostHog</title>
      <dc:creator>Phil Leggetter</dc:creator>
      <pubDate>Thu, 21 Oct 2021 17:08:15 +0000</pubDate>
      <link>https://forem.com/posthog/building-and-measuring-a-sign-up-funnel-with-supabase-nextjs-and-posthog-2hh9</link>
      <guid>https://forem.com/posthog/building-and-measuring-a-sign-up-funnel-with-supabase-nextjs-and-posthog-2hh9</guid>
      <description>&lt;p&gt;With the number of software frameworks and services available to help with developer productivity and feature building, it's never been a better time to be a software developer. One of most important things you'll have to build, whether building a SaaS, developer tool, or consumer app, is a sign up flow that begins on a landing page and ideally results in a successful sign up. The purpose of this sign up flow is to get as many real users through to being successfully signed up on your app or platform. So, it's important that you can measure whether your sign up flow is converting and where any potential sign ups are dropping out of that funnel.&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll create a simple sign up flow in a Next.js app, starting with a Supabase example for authentication. We'll then look at how you can instrument that sign up flow using the &lt;a href="https://posthog.comdocs/integrate/client/js"&gt;PostHog JavaScript SDK&lt;/a&gt; and create a sign up &lt;a href="https://posthog.comdocs/user-guides/funnels"&gt;funnel visualization&lt;/a&gt; within PostHog to analyze the success - or failure - of the sign up flow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you begin
&lt;/h2&gt;

&lt;p&gt;The application in this tutorial is built entirely upon open-source technologies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://nextjs.org/"&gt;Next.js&lt;/a&gt; is feature rich, Node.js open-source React framework for building modern web apps.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://supabase.io/"&gt;Supabase&lt;/a&gt; is an open-source alternative to Firebase offering functionality such as a Postgres database, authentication, realtime subscriptions and storage.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://posthog.com"&gt;PostHog&lt;/a&gt; is an open-source product analytics platform with features including feature flags, session recording, analysis of trends, funnels, user paths, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To follow this tutorial along, you need to have:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A &lt;a href="https://posthog.com/signup/self-host"&gt;self-hosted instance of PostHog&lt;/a&gt; or &lt;a href="https://app.posthog.com/signup"&gt;sign up for PostHog Cloud&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://supabase.io/docs/guides/hosting/overview"&gt;self-hosted instance of Supabase&lt;/a&gt; or &lt;a href="https://app.supabase.io/api/login"&gt;sign up for a hosted Supabase account&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://nodejs.org/en/download/"&gt;Node.js&lt;/a&gt; installed&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It's easier to get up an running with the cloud hosted options. If you want to go with self-hosted then the &lt;a href="https://posthog.comdocs/self-host/deploy/digital-ocean"&gt;DigitalOcean PostHog 1-click deployment&lt;/a&gt; makes getting started with PostHog much easier. For Supabase, &lt;a href="https://supabase.io/docs/guides/hosting/docker"&gt;the Docker setup&lt;/a&gt; appears to be the best option.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bootstrap sign up with Supabase Auth
&lt;/h2&gt;

&lt;p&gt;Rather than building sign up from scratch, let's instead start with an existing Supabase-powered example.&lt;/p&gt;

&lt;p&gt;Run the following in your terminal to bootstrap a Next.js application with pre-built sign up and login functionality:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-next-app &lt;span class="nt"&gt;--example&lt;/span&gt; https://github.com/PostHog/posthog-js-examples/tree/bootstrap/supabase-signup-funnel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will look similar to the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx create-next-app --example https://github.com/PostHog/posthog-js-examples/tree/bootstrap/supabase-signup-funnel
✔ What is your project named? … nextjs-supabase-signup-funnel
Creating a new Next.js app in /Users/leggetter/posthog/git/nextjs-supabase-signup-funnel.

Downloading files from repo https://github.com/PostHog/posthog-js-examples/tree/bootstrap/supabase-signup-funnel. This might take a moment.

Installing packages. This might take a couple of minutes.

Initialized a git repository.

Success! Created nextjs-supabase-signup-funnel at /Users/leggetter/posthog/git/nextjs-supabase-signup-funnel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll be prompted for a name for your app and the files will be downloaded into a directory with that name. The directory structure of your app will look as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.
├── README.md
├── components
│   └── Auth.js
├── lib
│   └── UserContext.js
├── package.json
├── pages
│   ├── _app.js
│   ├── api
│   │   ├── auth.js
│   │   └── getUser.js
│   ├── auth.js
│   └── profile.js
├── .env.local.example
├── style.css
└── utils
    └── initSupabase.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;components/Auth.js&lt;/code&gt; is the sign up, login, magic link, and forgot password component that makes use of Supabase Auth.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;lib/UserContext.js&lt;/code&gt; provides functionality to get the current user from within a component wrapped in a &lt;code&gt;&amp;lt;UserContext /&amp;gt;&lt;/code&gt;, if a user is logged in.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pages/_app.js&lt;/code&gt; a Next.js &lt;a href="https://nextjs.org/docs/advanced-features/custom-app"&gt;custom app component&lt;/a&gt; used to initialize all pages.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pages/api/*&lt;/code&gt; serverless API endpoints used within the Supabase authentication.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pages/auth.js&lt;/code&gt; is the authentication page that uses the &lt;code&gt;Auth&lt;/code&gt; component.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;pages/profile.js&lt;/code&gt; is a page used to demonstrate server-side rendering.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.env.local.example&lt;/code&gt; environment variables/configuration.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;styles.css&lt;/code&gt; basic styling.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;utils/initSupabase.js&lt;/code&gt; initializes a &lt;a href="https://supabase.io/docs/reference/javascript/supabase-client"&gt;Supabase client&lt;/a&gt; used to interact with Supabase.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we understand the basic structure of the bootstrapped application, let's get it up and running.&lt;/p&gt;

&lt;p&gt;The one last piece of setup that's required before running the app is to create a Supabase project, set some auth config, and add the credentials from that to a &lt;code&gt;.env.local&lt;/code&gt;. To create the &lt;code&gt;.env.local&lt;/code&gt; run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; .env.local.example .env.local
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, head to the &lt;a href="https://app.supabase.io/"&gt;Supabase dashboard&lt;/a&gt; to create a project. Click the &lt;strong&gt;New project&lt;/strong&gt; button and you'll be presented with a "Create new project" dialog.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fej3f0sziococid8iulj6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fej3f0sziococid8iulj6.png" alt="Supabase Create new project dialog" width="685" height="589"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may need to select an Organization. You will need to enter details for a project name, database password, and choose a deployment region. Once done, click the &lt;strong&gt;Create new project&lt;/strong&gt; button.&lt;/p&gt;

&lt;p&gt;You'll then be presented with a page showing &lt;strong&gt;Project API keys&lt;/strong&gt; and &lt;strong&gt;Project Configuration&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh1g8t7fkovwiam0rrv37.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh1g8t7fkovwiam0rrv37.png" alt="Supabase Project API keys and Project Configuration" width="733" height="647"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Update the contents of &lt;code&gt;.env.local&lt;/code&gt; as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Update the &lt;code&gt;NEXT_PUBLIC_SUPABASE_URL&lt;/code&gt; value to be the URL from &lt;strong&gt;Project Configuration&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Update the &lt;code&gt;NEXT_PUBLIC_SUPABASE_ANON_KEY&lt;/code&gt; value to be the API key tagged with &lt;code&gt;anon&lt;/code&gt; and &lt;code&gt;public&lt;/code&gt; from &lt;strong&gt;Project API keys&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next, within the Supabase dashboard project settings select &lt;strong&gt;Auth settings&lt;/strong&gt; and add &lt;code&gt;http://localhost:3000/auth&lt;/code&gt; to the &lt;strong&gt;Additional Redirect URLs&lt;/strong&gt; field.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiurxtsq1s8sen2fl9ljh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiurxtsq1s8sen2fl9ljh.png" alt="Supabase Auth settings" width="800" height="317"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the Supabase configuration in place, we can run the app with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can then navigate to &lt;code&gt;http://localhost:3000/auth&lt;/code&gt; to try out the Supabase authentication functionality including sign up, login, login/sign up with magic link (email), and forgot password.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa0quiorsjnzr7n9l1rje.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa0quiorsjnzr7n9l1rje.png" alt="Supabase basic authentication app UI" width="800" height="949"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you're signed up and logged in the UI will look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fro8mqjchmfi4oxyqk31n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fro8mqjchmfi4oxyqk31n.png" alt="Supabase Auth signed in example" width="800" height="949"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We'll focus on sign up for our application, so try out the sign up with email and password functionality as well as the magic link sign up (note magic link emails for a single email address can be sent once per 60 seconds).&lt;/p&gt;

&lt;p&gt;Once you're familiar with Supabase Auth functionality, we're ready to start to build a simple traditional sign up funnel.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build a sign up funnel
&lt;/h2&gt;

&lt;p&gt;The goal of this tutorial is to demonstrate how to instrument and measure a sign up flow. So, let's create a very simple sign up flow as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;User lands on the main website landing page which has two CTAs (call-to-actions) of &lt;strong&gt;SignUp&lt;/strong&gt;. One in the header and one in the landing page hero.&lt;/li&gt;
&lt;li&gt;User clicks on one of the sign up buttons and is taken to the sign up page.&lt;/li&gt;
&lt;li&gt;User enters their details to sign up and submits the form.&lt;/li&gt;
&lt;li&gt;User receives registration verification email.&lt;/li&gt;
&lt;li&gt;User clicks the link in the email and successfully signs up.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Signup flow landing page
&lt;/h3&gt;

&lt;p&gt;We'll keep the landing page really simple. Create a new file, &lt;code&gt;pages/index.js&lt;/code&gt;, with the following content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/link&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;curlPostCmd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`
curl -d '{"key1":"value1", "key2":"value2"\}' &lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;
     -H "Content-Type: application/json" &lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s2"&gt;
     -X POST https://api.awesomeapi.dev/data
`&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;curlGetCmd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`
curl -d https://api.awesomeapi.dev/data/{id}
`&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt; &lt;span class="na"&gt;maxWidth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;520px&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;96px auto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;fontSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;14px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;nav&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ul&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;logo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Awesome&lt;/span&gt; &lt;span class="nx"&gt;API&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Link&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;li&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/auth&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                                &lt;span class="nx"&gt;SignUp&lt;/span&gt;
                            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Link&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/li&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/ul&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/nav&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;header&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;logo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Awesome&lt;/span&gt; &lt;span class="nx"&gt;API&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Instantly&lt;/span&gt; &lt;span class="nx"&gt;build&lt;/span&gt; &lt;span class="nx"&gt;awesome&lt;/span&gt; &lt;span class="nx"&gt;functionality&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h2&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Link&lt;/span&gt; &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/auth&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class="nx"&gt;SignUp&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Link&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/header&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;main&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;POST&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/code&amp;gt; something Awesome&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;pre&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;curlPostCmd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/code&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/pre&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;GET&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/code&amp;gt; something Awesome&amp;lt;/&lt;/span&gt;&lt;span class="nx"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;pre&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;curlGetCmd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/code&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/pre&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/main&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;footer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;©️&lt;/span&gt;&lt;span class="nx"&gt;Awesome&lt;/span&gt; &lt;span class="nx"&gt;API&lt;/span&gt; &lt;span class="mi"&gt;2021&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/footer&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt; &lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;  &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Index&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As planned, the page has two CTA &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; elements that send the user to the &lt;code&gt;/auth&lt;/code&gt; page for sign up. One button is in the header and one is in what you could class as a "hero" location.&lt;/p&gt;

&lt;p&gt;This will result in an "Awesome API" landing page that looks as follows:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx010i2njcdg7zlyfu7ne.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx010i2njcdg7zlyfu7ne.png" alt="Awesome API example app landing page" width="800" height="949"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Feel free to rebrand!&lt;/p&gt;

&lt;p&gt;Now that a landing page is in place we have all the assets required for a basic sign up flow that we want the user to successfully navigate through.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1xna3dmswd7es9e2q9p5.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1xna3dmswd7es9e2q9p5.gif" alt="Supabase Next.js sign up flow animation" width="494" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Integrate with PostHog
&lt;/h2&gt;

&lt;p&gt;A user can now sign up with our app but there are a number of potential drop-off points within the funnel. So, let's integrate the PostHog JavaScript SDK to instrument the user sign up journey.&lt;/p&gt;

&lt;p&gt;Add two new environment variables to &lt;code&gt;.env.local&lt;/code&gt; that will be used with the PostHog JavaScript SDK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NEXT_PUBLIC_POSTHOG_API_KEY=your_posthog_api_key
NEXT_PUBLIC_POSTHOG_HOST=your_posthog_host
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The value for &lt;code&gt;NEXT_PUBLIC_POSTHOG_API_KEY&lt;/code&gt; can be found via &lt;strong&gt;Project&lt;/strong&gt; in the left-hand menu of your PostHog app, underneath the &lt;strong&gt;Project API Key&lt;/strong&gt; heading.&lt;/p&gt;

&lt;p&gt;The value for &lt;code&gt;NEXT_PUBLIC_POSTHOG_HOST&lt;/code&gt; is the public URL for your running PostHog instance. If you're using cloud, this is &lt;code&gt;https://app.posthog.com&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With the required config in place we can install the PostHog JavaScript SDK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm i &lt;span class="nt"&gt;-S&lt;/span&gt; posthog-js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a new file, &lt;code&gt;utils/initPostHog.js&lt;/code&gt;, and within it add code to initialize the PostHog JavaScript client:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;posthog&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;posthog-js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;initPostHog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;posthog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NEXT_PUBLIC_POSTHOG_API_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="na"&gt;api_host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NEXT_PUBLIC_POSTHOG_HOST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;posthog&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The file exports a single function, &lt;code&gt;initPostHog&lt;/code&gt;, that checks to ensure that the current runtime is the browser and, if so, initializes the PostHog JavaScript client with the config we've just stored. It also returns the &lt;code&gt;posthog&lt;/code&gt; client instance so we can use within our app.&lt;/p&gt;

&lt;p&gt;PostHog JS has an &lt;a href="https://posthog.comdocs/integrate/client/js#autocapture"&gt;autocapture&lt;/a&gt; feature that automatically captures browser events (this can be disabled). However, it won't capture navigation events in Next.js where the window doesn't reload, so we need to add some custom code to capture navigations.&lt;/p&gt;

&lt;p&gt;Open up &lt;code&gt;pages/_app.js&lt;/code&gt; and add this code within the &lt;code&gt;MyApp&lt;/code&gt; function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useRouter&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;next/router&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;initPostHog&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../utils/initPostHog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pageProps&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;router&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useRouter&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Init for auto capturing&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;posthog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;initPostHog&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleRouteChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;undefined&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;posthog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;capture&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;$pageview&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;routeChangeComplete&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleRouteChange&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;off&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;routeChangeComplete&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleRouteChange&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;router&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;events&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we import the &lt;a href="https://reactjs.org/docs/hooks-effect.html"&gt;React &lt;code&gt;useEffect&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://nextjs.org/docs/api-reference/next/router"&gt;Next.js Router&lt;/a&gt; hooks. Within the &lt;code&gt;useEffect&lt;/code&gt; hook we initialize the PostHog JS client using the function we've just created and bind to a &lt;code&gt;routeChangeComplete&lt;/code&gt; on the Next.js router, handling the event within the &lt;code&gt;handleRouteChange&lt;/code&gt; function. When this function is called, we manually trigger a &lt;code&gt;$pageview&lt;/code&gt; event using PostHog JS with &lt;code&gt;posthog.capture('$pageview')&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, restart your application so it picks up the new config in &lt;code&gt;.env.local&lt;/code&gt; and head over to the &lt;strong&gt;Events&lt;/strong&gt; section within your PostHog instance and you'll see new events appear as you test out the sign up flow.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fperctshn38slk4xume4w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fperctshn38slk4xume4w.png" alt="Signup funnel events in PostHog UI" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's how some of the events can tie in to the flow we're trying to build:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Event&lt;/th&gt;
&lt;th&gt;Url / Screen&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. User lands on the main website landing page&lt;/td&gt;
&lt;td&gt;Pageview&lt;/td&gt;
&lt;td&gt;locahost:3000/&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. User clicks on one of the sign up buttons&lt;/td&gt;
&lt;td&gt;clicked button with text "SignUp"&lt;/td&gt;
&lt;td&gt;locahost:3000/&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. User enters their details to sign up and submits the form&lt;/td&gt;
&lt;td&gt;submitted form&lt;/td&gt;
&lt;td&gt;localhost:3000/auth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. User receives registration verification email&lt;/td&gt;
&lt;td&gt;&lt;em&gt;no event&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;outside of app&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5. User clicks the link in the email and successfully signs up&lt;/td&gt;
&lt;td&gt;&lt;em&gt;no event&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;localhost:3000/auth&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;From the above table, you can see that we can track everything up until the sign up form submission.&lt;/p&gt;

&lt;p&gt;It is theoretically possible to track the step 4, email verification, if the email provider exposes an email sent notification mechanism via something like as a webhook. So, if Supabase offered a webhook when auth emails were sent we could track this from the server.&lt;/p&gt;

&lt;p&gt;However, we need and should be able to track step 5, when the user has successfully signed up. We know that the user lands on &lt;code&gt;/auth&lt;/code&gt; when they are logged in. If we look at the code for that page there is a &lt;code&gt;user&lt;/code&gt; variable that is set if the user is logged in. So, let's update &lt;code&gt;/pages/auth.js&lt;/code&gt; so we can track a logged in user. First, include the &lt;code&gt;initPostHog&lt;/code&gt; utility:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;initPostHog&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;../utils/initPostHog&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, update the &lt;code&gt;Index&lt;/code&gt; definition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useSWR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/getUser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;access_token&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fetcher&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;authView&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setAuthView&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sign_up&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;posthog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;initPostHog&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;posthog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;identify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;posthog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;capture&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;loggedIn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code we utilize the &lt;code&gt;initPostHog&lt;/code&gt; function again to reference an initialized PostHog JS instance. We then make two function calls:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;posthog.identify(user.email, user)&lt;/code&gt; - since the user is logged in we can identify them. We pass in &lt;code&gt;user.email&lt;/code&gt;, their email address, as a distinct identifier. We also pass in the Supabase &lt;code&gt;user&lt;/code&gt; variable so PostHog has access to additional user data.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;posthog.capture('loggedIn')&lt;/code&gt; - this triggers a simple &lt;code&gt;loggedIn&lt;/code&gt; event that we can use to identify the user as successfully having logged in.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you now go through the login flow, you can map all the required events in PostHog to the sign up funnel that we're building.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8ygxig6r0cg7su3uyec.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8ygxig6r0cg7su3uyec.png" alt="Mapping events in PostHog to the sign up funnel" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll also see the point at which &lt;code&gt;posthog.identify&lt;/code&gt; is called since the &lt;strong&gt;Person&lt;/strong&gt; associated with the event is now listed with each event entry.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: &lt;strong&gt;posthog.identify&lt;/strong&gt; is being called twice as the &lt;code&gt;Index&lt;/code&gt; function is likely being called twice during the React component life cycle as the values of state variables change.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a sign up funnel in PostHog
&lt;/h2&gt;

&lt;p&gt;Now that we have all the events for our sign up flow we can define a funnel to analyze the user journey and identify drop-off points.&lt;/p&gt;

&lt;p&gt;First, let's recap the events in the funnel and include the new &lt;code&gt;loggedIn&lt;/code&gt; event:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Event&lt;/th&gt;
&lt;th&gt;Url / Screen&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. User lands on the main website landing page&lt;/td&gt;
&lt;td&gt;Pageview&lt;/td&gt;
&lt;td&gt;locahost:3000/&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. User clicks on one of the sign up buttons&lt;/td&gt;
&lt;td&gt;clicked button with text "SignUp"&lt;/td&gt;
&lt;td&gt;locahost:3000/&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. User enters their details to sign up and submits the form&lt;/td&gt;
&lt;td&gt;submitted form&lt;/td&gt;
&lt;td&gt;localhost:3000/auth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. User receives registration verification email&lt;/td&gt;
&lt;td&gt;&lt;em&gt;no event&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;outside of app&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5. User clicks the link in the email and successfully signs up&lt;/td&gt;
&lt;td&gt;loggedIn&lt;/td&gt;
&lt;td&gt;localhost:3000/auth&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;To begin defining a funnel click on the &lt;strong&gt;New Insight&lt;/strong&gt; left-hand menu item within PostHog and select the &lt;strong&gt;Funnels&lt;/strong&gt; tab.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F082qb3k3mvoozu1b6s94.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F082qb3k3mvoozu1b6s94.png" alt="New Funnels Insight view" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the left-hand side of the view there is a panel with &lt;strong&gt;Graph Type&lt;/strong&gt; and &lt;strong&gt;Steps&lt;/strong&gt; headings. The &lt;strong&gt;Graph Type&lt;/strong&gt; value is set to &lt;strong&gt;Conversion steps&lt;/strong&gt;, which is what we want. The first of the &lt;strong&gt;Steps&lt;/strong&gt; is set to &lt;strong&gt;Pageview&lt;/strong&gt;. As we flesh out the steps, the funnel visualization will appear on the right.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1 - User lands on landing page
&lt;/h3&gt;

&lt;p&gt;The first step within the funnel is the user landing on the main website landing page with a path of &lt;code&gt;/&lt;/code&gt;. So, the event is correctly set to &lt;strong&gt;Pageview&lt;/strong&gt; but we need to filter the event by path. To do this, click the filter icon next to the step and filter on &lt;strong&gt;Path Name&lt;/strong&gt; where the path value is &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdz5vtd3yze7n0cabnv93.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdz5vtd3yze7n0cabnv93.png" alt="Step 1 - filter on landing page based on path name" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A funnel visualization won't appear at this point because a funnel must have more than one step.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2 - User clicks SignUp button
&lt;/h3&gt;

&lt;p&gt;To add the second step, click either of the &lt;strong&gt;Add funnel step&lt;/strong&gt; buttons. Change the event to &lt;strong&gt;Autocapture&lt;/strong&gt; since the event we're looking to make use of was one &lt;a href="https://posthog.comdocs/integrate/client/js#autocapture"&gt;autocaptured&lt;/a&gt; by the PostHog JS SDK. Then, set a filter. When you click the filter icon this time, select the &lt;strong&gt;Elements&lt;/strong&gt; tab and select the &lt;strong&gt;Text&lt;/strong&gt; property. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvlcqpkkk21seqe6daukt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvlcqpkkk21seqe6daukt.png" alt="Step 2 - user clicks sign up button filter on element text" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the filter value choose &lt;code&gt;SignUp&lt;/code&gt;, which should be pre-populated based on the values that PostHog has already ingested from our testing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ab05do8p5y0log2vj6x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2ab05do8p5y0log2vj6x.png" alt="Step 2 - user clicks sign up button filter on element text value" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you populate this step, you'll see the funnel visualization appear.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: you could also have done a &lt;strong&gt;Pageview&lt;/strong&gt; again here, filtered by a &lt;strong&gt;Path Name&lt;/strong&gt; value of &lt;code&gt;/auth&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3 - User submits sign up form
&lt;/h3&gt;

&lt;p&gt;For this step we want to track the sign up form submission. So, create a new step with an event of &lt;strong&gt;Autocapture&lt;/strong&gt; and a first filter on the &lt;strong&gt;Event Type&lt;/strong&gt; property (not be confused with the top-level event) with a value of "submit" for the form submission.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fygmq59e9dix8aoo7n1zq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fygmq59e9dix8aoo7n1zq.png" alt="Step 3 - filter on Event Type of submit" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, the above filter will track all form submissions. This may include forms other than the sign up form. So, add a second filter specifically identifying the sign up form based. To do this, select the &lt;strong&gt;Elements&lt;/strong&gt; tab, choose &lt;strong&gt;CSS Selector&lt;/strong&gt;, and set the selector value as &lt;code&gt;[id="sign_up_form"]&lt;/code&gt; to identify the &lt;code&gt;id&lt;/code&gt; attribute as having a value of &lt;code&gt;sign_up_form&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F12klv58n2m0otpu6lp45.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F12klv58n2m0otpu6lp45.png" alt="Step 3 - CSS Selector filter" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4 - User receives registration email
&lt;/h3&gt;

&lt;p&gt;As noted in the table above, we don't presently have a way of tracking this because it happens on systems outside of our control. Remember, though, it may be that an email provider could integrate with PostHog to also track email events.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F660dks8u2k2z7niy4wqa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F660dks8u2k2z7niy4wqa.png" alt="Step 4 - Supabase sign up verification email" width="800" height="693"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5 - User clicks on link in email and logs into app
&lt;/h3&gt;

&lt;p&gt;This represents successful completion of our sign up funnel. We added some custom code for this step earlier where a &lt;code&gt;loggedIn&lt;/code&gt; event was captured. Of course, for a user to have successfully logged in it does also mean that the sign up has been successful.&lt;/p&gt;

&lt;p&gt;So, add a new step to the funnel and select the &lt;code&gt;loggedIn&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2lmjin69k6yey2xynz4u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2lmjin69k6yey2xynz4u.png" alt="Step 5 - user signed up and logged in" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The funnel is now complete and we can see the journey of users through the sign up funnel, users that have dropped off, and users that have completed sign up.&lt;/p&gt;

&lt;p&gt;You can adjust the options in the right-hand panel, if required. For example, you can change the orientation of the funnel visualization from left-to-right to top-to-bottom, the computation in the steps from &lt;strong&gt;Overall converstion&lt;/strong&gt; to &lt;strong&gt;Relative to previous step&lt;/strong&gt;, and the period of time the Funnel is calculated over.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8by4hmu2w1euwekbej3d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8by4hmu2w1euwekbej3d.png" alt="Funnel visualization options" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, you can save the Funnel, giving it a name of &lt;strong&gt;Signup Funnel&lt;/strong&gt;, and add it to a Dashboard by clicking &lt;strong&gt;Save &amp;amp; add to dashboard&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3dco1swgze2to03gsqv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc3dco1swgze2to03gsqv.png" alt="Save and name sign up funnel" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this tutorial, you've learned how to create a sign up flow with Next.js and Supabase Auth. You've then ensured all the necessary application events are being ingested into PostHog. This then allows you to define the sign up flow as a sign up Funnel so you can measure the success of the user journey and identify where users drop off.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where next?
&lt;/h2&gt;

&lt;p&gt;Here are a few examples of where you could explore next.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Actions instead of Events
&lt;/h3&gt;

&lt;p&gt;We've made extensive use of &lt;a href="https://posthog.comdocs/user-guides/events"&gt;Events&lt;/a&gt; within this tutorial. However, it can be beneficial to wrap events up into something called &lt;a href="https://posthog.comdocs/user-guides/actions"&gt;Actions&lt;/a&gt;. Actions let you group multiple events which can then be used within Insights, such as Funnels.&lt;/p&gt;

&lt;p&gt;For example, in this tutorial we used an &lt;strong&gt;Event Type&lt;/strong&gt; and a &lt;strong&gt;CSS Selector&lt;/strong&gt; to track the sign up form submission. If we were to instead create an Action and call it &lt;strong&gt;Sign up form submitted&lt;/strong&gt; this Action could be used within the Sign up Funnel and also easily reused within other Insights. So, why not take a look at creating some reusable Actions, update the existing Funnel to use them, and try creating some other Insights?&lt;/p&gt;

&lt;h3&gt;
  
  
  Track email sending
&lt;/h3&gt;

&lt;p&gt;We were unable to track the email sending within this tutorial. How about exploring a way to add capture a &lt;code&gt;signUpEmailSent&lt;/code&gt; event within PostHog when the verification email is sent?&lt;/p&gt;

&lt;p&gt;There are a couple of options here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Supabase uses a tool called &lt;a href="https://github.com/supabase/gotrue"&gt;GoTrue&lt;/a&gt; which does support webhook configuration for email events such as &lt;code&gt;validate&lt;/code&gt;, &lt;code&gt;signup&lt;/code&gt; or &lt;code&gt;login&lt;/code&gt;. Why not get involved in the Supabase community and see if these events can be exposed via Supabase?&lt;/li&gt;
&lt;li&gt;Turn on &lt;strong&gt;Enable Custom SMTP&lt;/strong&gt; within Supabase and use a third-party email provider that exposes webhooks for email events?&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>nextjs</category>
      <category>supabase</category>
      <category>javascript</category>
      <category>analytics</category>
    </item>
  </channel>
</rss>
