Choose an install method
The script tag is the shortest path. It looks like this:
cs_pk_xxxxxxxx with your site’s public key and example.com with your domain. data-domains keeps the script quiet on preview deployments, workers.dev copies, staging hosts and scraped copies of your site, so they are not counted. Use a classic script tag with defer or async. type="module" does not work, because the script reads its options from its own tag.
Find your public key
Every site has a public key that starts withcs_pk_. It tells the collector which site an event belongs to. It is safe to publish: all it can do is send events to that site.
You can find it in three places:
- Settings, Tracking code: the Public key panel shows the key with a copy button, and every snippet on that tab already has the key filled in.
- The command menu: the Copy tracking snippet action copies the plain script tag for the site you have open.
- Onboarding: the Install the script step shows the same platform tabs, with the key filled in, right after you add a site.
Copy the exact code for your platform
The Tracking code tab in your site settings shows the same script, placed where each platform wants it, with tabs for HTML, Next.js, React and Vite, Vue and Nuxt, Astro, SvelteKit, Remix and React Router, WordPress, Webflow, Framer, Shopify and Google Tag Manager. Each tab says where the code goes, writesdata-domains with your site’s domain and additional hostnames, and adds data-keep-params and data-persist when your settings need them. The switches add an attribute to every tab at once:
No switch is on by default. Leave Hash routing off for frameworks that route with real paths (Next.js, Nuxt, SvelteKit, Astro, Remix): it only reads routes written after
#, such as /#/pricing.
The switches only change the snippet you copy. An option starts working once the updated snippet is on your site. Script attributes lists every attribute, including the ones that are not switches.
Platform guides
Plain HTML
Paste the tag in
<head> on every page.Google Tag Manager
A Custom HTML tag on All Pages.
WordPress
A
wp_head action in functions.php or a site plugin.Webflow
Site settings, Custom code, Head code.
Framer
Site settings, General, Custom code.
Shopify
layout/theme.liquid, above </head>.Wix
Settings, Custom Code, in the head on all pages.
Squarespace
The Header field of Code Injection.
Ghost
Settings, Advanced, Code injection, Site header.
Framework guides
Next.js
next/script in the root layout.React and Vite
The tag in
index.html.Vue and Nuxt
app.head in nuxt.config.ts.Astro
The tag with
is:inline in your layout.SvelteKit
The tag in
src/app.html.Remix
The tag in
app/root.tsx.Angular
The tag in
src/index.html.Svelte
The tag in
index.html, for Svelte with Vite.TypeScript
Types for the global and the queue stub.
Static site guides
Gatsby
onRenderBody in gatsby-ssr.js.Hugo
Your head partial, overriding the theme’s.
Jekyll
_includes/head.html in your site.Eleventy
The base layout in
_includes.Docusaurus
The
scripts array in docusaurus.config.js.Server framework guides
Laravel
Your Blade layout.
Ruby on Rails
application.html.erb. Turbo is tracked.Django
base.html.Flask
Your base Jinja template.
Switching from another tool
Only Plausible history can be imported; from other tools, run both side by side for a while. The switching guides map events and goals across: Google Analytics 4, Plausible, Umami and Fathom.Confirm the install
Open Settings, Tracking code. The status row at the top checks every few seconds and shows Receiving events. once the first event from your site has been stored. Visits fromlocalhost, *.localhost, 127.x.x.x, [::1], file:// and automated browsers are ignored, so open your deployed site in a normal browser window. To test before you ship, see localhost and testing. If nothing arrives, work through troubleshooting.
Next steps
Install on a plain HTML site
The full procedure, with optional modules and the install check.
Script attributes
Every
data- attribute the script reads.Serve the script from your domain
Count visitors whose ad blocker stops analytics hosts.