> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maqetin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Privacy and device storage

> The fields the JavaScript SDK collects, every read and write it makes on the visitor's device, and how to stop each one.

This covers the main entry, `@maqetin/sdk-js`, version 0.2.0. The server entry runs in Node and touches no visitor's device. Name these fields in your privacy notice.

## What the SDK collects

| Field | What it holds |
| - | - |
| `timezone`, `locale` | The IANA time zone and the language of the browser |
| `deviceId`, `anonymousId` | Random ids the SDK makes and keeps in the browser's storage. Never an advertising id |
| `userAgent` | The string the browser sends to name itself |
| `page.url`, `page.path`, `page.referrer` | The address of the page and of the page before it. The SDK drops the query string and the fragment, which can hold tokens, reset links and email addresses |
| `page.title` | The page title as your page sets it. If your titles hold a name, so does this field |
| `campaign` | The `utm_source`, `utm_medium`, `utm_campaign`, `utm_term` and `utm_content` of the address, only when it has them |

`disableAutoCollection: true` leaves these out of `context`. Two still go out: `anonymousId`, on every call, and the page, in page view properties until you set `autoPageViews: false`. `storage: memoryStorage()` keeps the three ids in memory: they last until the page closes, and a visitor is identified on that page only.

```ts theme={null}
import { MaqetinClient, memoryStorage } from '@maqetin/sdk-js';

const mq = new MaqetinClient({
  publicKey: 'mq_live_…',
  disableAutoCollection: true,
  autoPageViews: false,
  storage: memoryStorage(), // keep nothing on the device
});
```

## What the SDK reads and writes on the device

Every read and write started in version 0.1.0. None asks the browser for a permission, and the SDK sets no cookie.

| What | Read or write | When | Why | How to stop it |
| - | - | - | - | - |
| `localStorage` key `maqetin.anonymousId` | Read and write | When the client starts; written again by `reset()` | Links a visitor's events before and after they sign in | `storage: memoryStorage()`: the id lasts until the page closes |
| `localStorage` key `maqetin.userId` | Read, write and remove | Read when the client starts, written by `identify`, removed by `reset()` | Keeps the visitor identified after a page load | `storage: memoryStorage()`: the visitor is identified on that page only |
| `localStorage` key `maqetin.deviceId` | Read and write | Read when the client starts, to learn whether the page may use storage; then read with each call, and written the first time | `context.deviceId`: tells one browser of a person from another | `disableAutoCollection: true` stops it with each call; `storage: memoryStorage()` stops the read at start as well |
| Time zone (`Intl.DateTimeFormat().resolvedOptions().timeZone`) | Read | With each call | `context.timezone`, kept on the person's profile | `disableAutoCollection: true` |
| Language (`navigator.language`) | Read | With each call | `context.locale`, kept on the person's profile | `disableAutoCollection: true` |
| The string the browser sends to name itself (`navigator.userAgent`) | Read | With each call | `context.userAgent` | `disableAutoCollection: true` |
| Page address (`location.href`) | Read | With each call, and with each page view | `context.page`, `context.campaign` and the page view's properties. The query string and the fragment are dropped; only the `utm_*` values are taken from the query | `disableAutoCollection: true`, `autoPageViews: false`, and no `page()` call |
| Page address (`location.href`) | Read | When the client starts, only if `endpoint` is a path | Makes the full address of your endpoint; nothing is sent | Give `endpoint` as a full `https://` address |
| Referring page (`document.referrer`) | Read | With each call, and with each page view | `context.page.referrer` and the page view's `referrer`, without the query string or the fragment | `disableAutoCollection: true`, `autoPageViews: false`, and no `page()` call |
| Page title (`document.title`) | Read | With each call, and with each page view | `context.page.title` and the page view's `title` | `disableAutoCollection: true`, `autoPageViews: false`, and no `page()` call |

If the browser refuses storage, the three ids last until the page closes.

The client also listens for `pagehide`, `visibilitychange` and `popstate`, and wraps `history.pushState` and `history.replaceState`, to send queued calls before the page closes and to see a new path. These read only whether the page is hidden.


## Related topics

- [JavaScript SDK](https://docs.maqetin.com/sdk/javascript.md)
- [Profiles](https://docs.maqetin.com/data/profiles.md)
- [Contacts](https://docs.maqetin.com/data/contacts.md)
- [Events](https://docs.maqetin.com/data/events.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.