# The Privatus Analytics app for Shopify

> How the Privatus Analytics app for Shopify connects your store to a site, turns on the tracking script with an app embed and what it can read.

> **Warning:** The app is not in the Shopify App Store. Don't install an
> app called Privatus Analytics from the store: it is not ours, whoever
> published it. Use the [theme code](/docs/install/shopify) until this
> page says the app is listed.

The app does three things in your Shopify admin: it connects your store
to a Privatus Analytics site, it switches on an app embed that adds the
tracking script to every page of your theme, and it adds a web pixel that
counts add to carts, checkouts and purchases. It is free to install. Your
Privatus Analytics plan is the same as on our site.

## Connect your site

Open **Apps, Privatus Analytics** in your Shopify admin. Under
**Connect your site**, paste your site id (`pa_...`, under **Site
settings, Setup**) and click **Save**.

No site id yet? Click **Log in or create a free account**.
Privatus Analytics opens in a new tab. Log in, or sign up, and allow the app to
read your workspace. A new account gets a site for your store's domain.
If your workspace already has a site for that domain, it is used.
Otherwise you pick one. When the tab says your store is connected, close
it: the app page shows the connection when you go back to it.

The site id is written to the app's own setting in your store, where the
app embed reads it, and into the app's web pixel. **Disconnect** takes it
off again: the embed then prints nothing and the pixel is deleted.

## Turn on the app embed

Click **Open the theme editor**. It opens your live theme with the app
embeds panel. Switch on **Privatus Analytics** and click **Save**. The
app page then says the embed is on.

The embed adds the [tracking script](/docs/install) to the `<head>` of
every page, masks order pages (`/account/orders/:id`) and stays out of the
theme editor, so editing your theme adds no visits. Its other settings
(single-page mode, modules, allowed domains, excluded paths, path masks)
are optional and match the script's [attributes](/docs/tracker/attributes).
The script loads from `https://privatusstats.com`, the Privatus Analytics
tracker host.

## Checkout and purchases

Shopify's checkout runs outside your theme, so the app embed can't see
it. When you connect a site, the app adds a web pixel to your store
(**Settings, Customer events** lists it). It runs in Shopify's sandbox
in your visitor's browser and sends three [custom events](/docs/events)
to `https://privatusstats.com/api/event`, the same address the tracking
script uses:

| Event | When | What it adds |
|---|---|---|
| `Add to Cart` | A product is added to the cart | Nothing |
| `Checkout Started` | The visitor starts checkout | Nothing |
| `Purchase` | The order is placed | The order total and its currency, as [revenue](/docs/events/revenue) |

Each event also has the page address (with checkout and order addresses
reduced to `/checkout` and `/checkout/thank-you`, and only campaign
parameters kept), the referrer's address without its query, the browser
language and the screen width. The pixel never sends a customer's name,
email, phone, address, order id, checkout token or Shopify's client id,
sets no cookies and writes nothing to the visitor's browser. It does not
count pageviews: those come from the app embed, so nothing is counted
twice.

`Purchase` is counted on the thank-you page, so an order whose page never
loads is missed: treat the totals as close, not exact. If your checkout
runs on your `myshopify.com` address rather than your own domain, add
that address as an
[additional domain](/docs/getting-started/add-a-site#more-settings-under-site-settings-general),
or the events are dropped.

### Cookie consent

By default the pixel does not wait for your store's cookie banner,
because Privatus Analytics sets no cookies and stores no personal data.
Whether your store needs consent for it depends on the laws that apply
to you, so check with your own legal adviser. To wait, switch on
**Respect the store's cookie consent** in the app. The pixel then sends
these three events only for visitors who allow analytics in your store's
banner (Shopify's Customer Privacy API). It doesn't change the app embed.

## What the app can read

The app asks for three permissions: reading your themes (`read_themes`),
so it can tell you whether the embed is on, and editing web pixels and
reading customer events (`write_pixels`, `read_customer_events`), so it
can add, update and delete its own pixel. It does not read orders,
customers or products through Shopify's API. We keep your store's
`myshopify.com` address, its own domain, the connected site and Shopify's
access token, which is encrypted. The pixel's settings (the site id and
the consent switch) are kept by Shopify, not by us. Uninstalling the app
deletes the token at once and Shopify removes the pixel, and Shopify's
request to delete your store's data 48 hours later deletes the rest.
