Dokumentaatio
Selaa dokumentaatiota

Add Privatus Analytics to a Netlify site

Add cookieless analytics to any site hosted on Netlify with snippet injection, with no code change or redeploy, and leave deploy previews out of your reports.

Näytä Markdown-muodossa

Netlify can add the snippet to every page it serves, without a change to your code and without a redeploy.

  1. In your project go to Project configuration → Developer settings → Post processing.
  2. Under Snippet injection, click Add snippet.
  3. Choose Insert before </head>, name it "Privatus Analytics" and paste the snippet:
html
   <script defer src="https://privatusstats.com/js/pa.js" data-site="pa_YOURSITEID" data-modules="engage,auto,vitals,clicks,ask"></script>
  1. Save. The snippet is added to pages as they are served.

Netlify does not inject snippets into proxied routes or routes handled by Netlify Functions, which includes server-rendered pages. For those, add the snippet to your framework's layout instead, for example with the Next.js or Astro guide.

Deploy previews#

Hits are only stored for hostnames that are among the site's domains, so visits to *.netlify.app deploy previews are dropped unless you add that domain as an additional domain. To leave the snippet out of previews entirely, wrap it in Netlify's CONTEXT variable:

liquid
{% if CONTEXT == 'production' %}
<script defer src="https://privatusstats.com/js/pa.js" data-site="pa_YOURSITEID" data-modules="engage,auto,vitals,clicks,ask"></script>
{% endif %}