# Install with your AI assistant

> Say "Install Nvivio" to your AI assistant and it asks what to measure, sets up your website and your iOS or Android app, and says what is left for you.

Say "Install Nvivio" to Claude Code, Cursor, Copilot, Lovable, Bolt or another coding assistant. It finds these instructions by itself (as an [agent skill](https://nvivio.com/.well-known/agent-skills/index.json) and in [/llms.txt](https://nvivio.com/llms.txt)), looks at your project, asks what you want to measure, and installs it: the script on your website, the SDK in your iPhone or Android app.

The fastest way: in the dashboard, open **Settings › Installation** and choose **Copy the prompt for your AI**. That prompt already contains your site's code, your domains and the apps you registered, so your assistant asks less. Only an app to set up? The iOS and Android tabs of **Add the SDK to your app** (under **Settings › Parts**) each have a prompt for that one platform ([Measure your app](https://nvivio.com/docs/apps#add-your-app)).

## What your assistant asks you

- **Your site's code**, if you did not paste the prompt and your assistant is not [connected to Nvivio](https://nvivio.com/docs/mcp). It looks like `NV-XXXXXXX` and is in **Settings › Installation**. No account yet? Make one at [nvivio.com/app](https://nvivio.com/app): it is free, needs no credit card, and you log in with a link by email.
- **What to measure.** It says what it found in your project, and asks about the rest, for example: "This is a Next.js website. Do you also have an iPhone or Android app you want to measure?" It installs only what you confirm, and only in the code it can reach. For an app in another project, paste the same prompt there.
- **For a React Native or Flutter app:** whether to call the iOS and Android SDK from a small native module, or to send the requests itself. There is no package for these frameworks yet.

## What is left for you

Your assistant has no access to your Nvivio account, so a few steps are yours. It tells you which, with the address:

1. **Register your app.** An app only counts once its bundle ID (iOS) or package name (Android) is listed under **Settings › Parts › + App** ([Measure your app](https://nvivio.com/docs/apps#add-your-app)).
2. **See the first visit.** Open **Settings › Installation** and visit your site or open your app once: the page switches to **It works** as soon as the first visit arrives.
3. **Fill in the stores' privacy forms** for an app. Your assistant gives you the answers for the App Store and Google Play ([Privacy and the stores](https://nvivio.com/docs/apps#privacy-and-the-stores)), and can add a sentence about Nvivio to your privacy policy.

## For AI assistants

These are the steps to install Nvivio for a user. If the user pasted a prompt from Nvivio's installation page, follow that prompt: it has the same steps with the site's own code, domains and registered apps filled in.

### 1. Get the site code

The site code is `NV-` followed by seven letters and digits. If [Nvivio's MCP server](https://nvivio.com/docs/mcp) is connected, the tool `list_sites` gives it as each site's `id`: pick the site whose domain matches the project, and ask when there are several. Otherwise ask the user for it, from **Settings › Installation** (`https://nvivio.com/app/<their-domain>/install`), or for the prompt on that page. Never invent a code. If they have no account, tell them to make one at https://nvivio.com/app (free, no credit card) and add their website; you cannot do that for them.

### 2. Find out what to measure

Look at the project, say what you found, then ask the user in one short message about what you cannot tell from it:

| What you find | What measures it |
|---|---|
| A website, web app or PWA, or pages of the website inside an app (a web view) | The script line: step 3. |
| A native iOS or iPadOS app (Swift, SwiftUI, UIKit) | The Swift package: step 4. |
| A native Android app (Kotlin, Java, Jetpack Compose) | The Android library: step 5. |
| React Native, Flutter, Unity or another framework | No package yet: step 6. |

Always ask once whether there is more to measure than this project, for example: "Do you also have an iPhone or Android app you want to measure with Nvivio?" Install only what the user confirms.

### 3. A website

Insert the line once, in the `<head>` of every page (the shared layout):

```html
<script defer src="https://nviv.io/js/NV-XXXXXXX.js"></script>
```

| Framework | Where |
|---|---|
| Plain HTML | The `<head>` of every page, or the shared layout or partial. |
| Next.js | App Router: `<Script src="https://nviv.io/js/NV-XXXXXXX.js" strategy="afterInteractive" />` from `next/script` in `app/layout.tsx`. Pages Router: the same in `pages/_app.tsx`. |
| Astro | The shared layout's `<head>`, with `is:inline`. |
| SvelteKit | `src/app.html`, inside `<head>`. |
| Nuxt | `nuxt.config.ts`: `app.head.script: [{ src: "https://nviv.io/js/NV-XXXXXXX.js", defer: true }]`. |
| Vite, React or Vue | `index.html`, inside `<head>`. |
| Remix or React Router | `app/root.tsx`, inside `<head>`. |
| WordPress, Webflow, Framer, Shopify, Google Tag Manager | See [Install the script](https://nvivio.com/docs/install#by-platform); WordPress has [a plugin](https://nvivio.com/docs/wordpress), Shopify [its own page](https://nvivio.com/docs/shopify), Google Tag Manager [a template](https://nvivio.com/docs/google-tag-manager). |

Do not add the line twice, and do not wrap it in a consent check: it sets no cookies. Client-side navigation counts by itself. With a Content-Security-Policy, allow `https://nviv.io` in `script-src` and `connect-src`. Events from `localhost` are refused with 403, which is expected during development. Custom events: [Script reference](https://nvivio.com/docs/script).

Check after deploying: the live HTML loads `https://nviv.io/js/NV-XXXXXXX.js` once, and that address answers 200.

### 4. An iOS app

1. Add the Swift package `https://github.com/montobleu/nvivio-swift` (Xcode: **File › Add Package Dependencies**), product `Nvivio`. iOS and iPadOS 15 or later.
2. Start it once when the app starts: `Nvivio.start(site: "NV-XXXXXXX")`, in the `App`'s `init()` in SwiftUI or in `application(_:didFinishLaunchingWithOptions:)` in UIKit.
3. Name the screens: `.nvivioScreen("Checkout")` on a SwiftUI view, or `Nvivio.screen("Checkout")` in `viewDidAppear`.
4. Optional: `Nvivio.event("Purchase", ["plan": "pro"])`, and `Nvivio.open(url)` for the deep link that opened the app.

### 5. An Android app

1. In `settings.gradle.kts`, add `maven("https://jitpack.io")` to `dependencyResolutionManagement.repositories`.
2. In the app module's `build.gradle.kts`: `implementation("com.github.montobleu:nvivio-android:1.0.0")`. Android 6 (API 23) or later; it needs only the `INTERNET` permission.
3. In the `Application` class (make one and register it in `AndroidManifest.xml` if there is none): `import com.nvivio.Nvivio`, then `Nvivio.start(this, "NV-XXXXXXX")` in `onCreate()`. With `trackActivities = true` every activity counts as a screen by itself.
4. Name the screens with `Nvivio.screen("Checkout")` in `onResume` or a `LaunchedEffect`; optional `Nvivio.event("Purchase", mapOf("plan" to "pro"))` and `Nvivio.open(uri)`.

### 6. React Native, Flutter and others

There is no package yet. Ask the user whether to call the iOS and Android SDK from a small native module, or to send the requests as [the protocol](https://github.com/montobleu/nvivio-swift/blob/main/PROTOCOL.md) describes.

### 7. Rules for apps

- Screen names are names, not data: `Checkout`, never `Order 1234`.
- Add no consent prompt and no App Tracking Transparency prompt for Nvivio: the SDK uses no advertising or device identifiers and stores nothing on the phone. If the app has its own analytics switch, set `Nvivio.isEnabled` from it at every start.
- The app counts only once its bundle ID or package name is under **Settings › Parts** of the site. You cannot add it: give the user the exact ID from the project and the address `https://nvivio.com/app/<their-domain>/settings#parts`. Debug builds with a suffix such as `.debug` need that ID too.
- Check with `Nvivio.debug = true` in a debug build: the SDK logs each request (Xcode console, or Logcat tag `Nvivio`). 204 means it arrived, 403 that the app ID is not registered, 404 that the site code is wrong.

### 8. Tell the user

Say what you installed and where, and what is left for them: registering an app's ID, opening **Settings › Installation** to see the first visit arrive, and for an app the answers for the stores' privacy forms from [Privacy and the stores](https://nvivio.com/docs/apps#privacy-and-the-stores).
