Skip to content
Getting started / Install the script

Getting started

Install the script

Add PlainAnalytics to your website with one snippet, a CMS, Google Tag Manager or npm.

Adding PlainAnalytics takes a couple of minutes. You'll need an account and access to your site's HTML (or its CMS or tag manager).

1. Add your site

Log in, click + Add website on your sites list and enter your domain without https:// or www. — for example example.com. Choose the timezone you want your reports in, then continue to the installation page.

2. Copy your snippet

Every site gets its own script, shown on the installation page (and later under Site settings → General → Site installation). It looks like this:

<!-- Privacy-friendly analytics by Plain -->
<script async src="https://plainwebanalytics.com/js/pa-XXXXXXXXXXXXXXXXXXXXX.js"></script>
<script>
  window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};
  plausible.init()
</script>

Paste it into the <head> of every page you want to measure, ideally in a shared layout or template.

  • The first <script> loads the tracker asynchronously, so it never blocks your page from rendering.
  • The second line creates a small queue, so plausible() calls made before the script has loaded aren't lost.

Your site-specific script already knows your domain and the tracking options you've switched on in the dashboard. When you change an option later, the script updates by itself — you never need to touch the snippet again.

Other ways to install

WordPress

Use a header and footer plugin (such as WPCode) to add the snippet as a site-wide header snippet, or add it to your child theme's header.php just before </head>.

Google Tag Manager

  1. Create a new tag of type Custom HTML.
  2. Paste the snippet into the HTML field.
  3. Set the trigger to Initialization – All Pages, save, and publish your container.

npm (JavaScript apps)

If you bundle your front end, you can use the open-source @plausible-analytics/tracker package — its API is compatible with PlainAnalytics. Point the endpoint at PlainAnalytics:

import { init } from '@plausible-analytics/tracker'

init({
  domain: 'example.com',
  endpoint: 'https://plainwebanalytics.com/api/event',
})

Single-page apps

Nothing extra is needed. The script records a pageview whenever your router calls history.pushState or the visitor uses the back and forward buttons. If your app routes with #/hash URLs, turn on hash-based routing (see Script options).

Tracking options

On the installation page and in Site settings → General you can switch on:

Option What it does
Outbound links Records a Outbound Link: Click event when someone follows a link to another site
File downloads Records a File Download event for links to files such as PDFs, ZIPs and spreadsheets
Form submissions Records a Form: Submission event when a form is submitted
Hash-based routing Treats /#/pricing and /#/about as separate pages
Tagged events Lets you track clicks with CSS classes instead of JavaScript
Manual pageviews Stops automatic pageviews so you can send them yourself
Track localhost Records visits from localhost, useful while developing

Each is described in detail in Script options.

Next step

Visit your site, then verify your installation.

Something unclear or missing? Tell us.