Install Privatus Analytics on Shopify
Add cookieless analytics to your Shopify store with the app embed or theme code, then track checkout purchases and revenue with a Shopify custom pixel.
Storefront#
- Install the Privatus Analytics app. If it isn't listed in the Shopify App Store yet, use the steps under Without the app.
- Go to Online Store → Themes → Customize → App embeds and switch on Privatus Analytics.
- Enter your site id (
pa_…) and choose modules. Engagement is on by default. Auto events, Web Vitals and click maps are optional. - Save.
The embed prints the tracker in the theme's <head> and masks
customer-specific order pages (/account/orders/*). It isn't loaded in the
theme editor, so editing your theme doesn't add visits.
Without the app#
Edit your theme (Online Store → Themes → … → Edit code), open
layout/theme.liquid and add the snippet before </head>:
<script defer src="https://privatusanalytics.com/js/pa.js" data-site="pa_YOURSITEID"
data-mask="/account/orders/*->/account/orders/:id"></script>
Checkout and purchases#
Shopify's checkout doesn't run theme scripts. Use a custom pixel under Settings → Customer events → Add custom pixel:
// Privatus Analytics: purchases (runs in Shopify's sandbox)
const SITE = 'pa_YOURSITEID'
const ENDPOINT = 'https://privatusanalytics.com/api/event'
function send(body) {
fetch(ENDPOINT, {
method: 'POST', keepalive: true, credentials: 'omit',
headers: { 'Content-Type': 'text/plain' },
body: JSON.stringify(Object.assign({ s: SITE }, body))
})
}
analytics.subscribe('checkout_completed', (event) => {
const checkout = event.data.checkout
send({
t: 'event', n: 'purchase', u: event.context.document.location.href,
p: {
revenue: Number(checkout.totalPrice.amount),
currency: checkout.totalPrice.currencyCode,
items: checkout.lineItems.length
}
})
})
Set Permission to "Not required" only if your legal assessment allows it. Privatus sets no cookies and stores nothing on the device. Never add order ids, emails or names as properties.
Your storefront domain (shop.example.com) and your myshopify.com
domain may both appear. Add both as extra domains
if you want hits from both.