Install in pages/_app.js

The easiest way to install Koala on Next.js applications is to add it to the main _app.js file.

Copy the Koala snippet from your workspace installation settings page and paste it into the Script component.

import Script from 'next/script'
export default function MyApp({ Component, pageProps }) {
  return (
          __html: `// Paste your Koala snippet here`
      <Component {...pageProps} />

Alternatively, you can install Koala in the <head> or <body> of your site by adding the snippet to the pages/_document.js file.

import { Head, Html, Main, NextScript } from 'next/document'

export default function KoalaDocument() {
  return (
            __html: `// Paste your Koala snippet here`,
        <Main />
        <NextScript />

Identify visitors

Once you’ve installed the snippet, you can also start identifying known visitors.

window.ko?.identify('[email protected]', {
  name: 'Jane Doe',
  title: 'Product Manager'

Learn more about identifying visitors or setting visitor/account traits in our guide: Identifying visitors.