[Docs](https://userjourney.dev/docs/) · Install

# Add UserJourney to a Vue or Nuxt app

For a Vue single-page app and for Nuxt.

## 1. The snippet

In Vue, in `index.html`'s `<head>`:

```
<script src="https://userjourney.dev/uj.js" data-key="pk_…" defer></script>
```

In Nuxt, in `nuxt.config.ts`:

```
export default defineNuxtConfig({
  app: {
    head: {
      script: [{ src: "https://userjourney.dev/uj.js", "data-key": "pk_…", defer: true }],
    },
  },
});
```

Your key is on the Setup page of the dashboard. Route changes count as page views by themselves.

## 2. A small helper

So you can call it from your components, even before the script has loaded:

```
// utils/uj.ts
type Method = "identify" | "reset" | "step" | "activated" | "track" | "search";

/** Calls UserJourney's snippet; before it has loaded, the call waits in its queue. */
export function uj(method: Method, ...args: unknown[]) {
  if (typeof window === "undefined") return;
  const w = window as unknown as { uj?: Record<string, unknown> & { q?: unknown[][] } };
  const fn = w.uj?.[method];
  if (typeof fn === "function") fn(...args);
  else ((w.uj ??= { q: [] }).q ??= []).push([method, ...args]);
}
```

## 3. Identify

Where your app learns who is signed in, for example next to your auth store. The first call for someone is their sign-up.

```
import { watch } from "vue";
import { uj } from "@/utils/uj";

watch(
  () => user.value?.id,
  () => {
    if (user.value) uj("identify", String(user.value.id), { email: user.value.email, name: user.value.name });
  },
  { immediate: true },
);

// on sign-out
uj("reset");
```

## Onboarding steps

Pages under `/onboarding/<step>`, `/setup/<step>`, `/welcome/<step>` or `/get-started/<step>` count as steps by themselves. Otherwise, one call when each step is done, and optionally the moment they first get value:

```
uj("step", "connect_repo")
uj("activated")
```

## Payments

Connect [Stripe](https://userjourney.dev/docs/stripe/) or [Paddle](https://userjourney.dev/docs/paddle/) in the dashboard, and each payment, trial and cancellation lands on the person who made it.

## Check it works

Open your site in a private window: you show up on Traffic within a few seconds. Sign up with a test account and it appears on People, with the visit that brought it. Your own team is left out once you sign in; for your visits before that, open any page once with `?uj=off` ([more](https://userjourney.dev/docs/#leave-out)).

If your app sends a Content Security Policy, add `https://userjourney.dev` to `script-src` and `connect-src`.

[Everything else is in the docs →](https://userjourney.dev/docs/)

## See where your users go

Free for your first 250 users. One script and one line of code.

[Start for free](https://userjourney.dev/app)[Read the quickstart](https://userjourney.dev/docs/)
