Skip to main content
Focustivity

Add Plausible Analytics to your Obsidian Publish site


Obsidian Publish allows adding JavaScript, which means you can add a Plausible Analytics tracking code to your site.

Configure Plausible Analytics

  1. Create your Obsidian Publish site in your Plausible Analytics account.
  2. Grab your tracking code.

Configure Obsidian Publish

  1. Create a file named publish.js in the root of your Obsidian vault. Create this file from file explorer, not from within Obsidian!
  2. Copy the below script to the publish.js file.
  3. Update the data-domain and src to the values provided in the Plausible script.
  4. Save and publish the publish.js file to your Obsidian Publish site!
  5. Open your Plausible Analytics page and refresh your Obsidian Publish page. Plausible Analytics should recognize an active visitor to the site.
var analyticsScript = document.createElement('script');
	analyticsScript.defer = true;
    analyticsScript.data-domain = "yourdomain.com";
    analyticsScript.src = '[plausible.io/js/script...(https://plausible.io/js/script.js';)
    document.head.appendChild(analyticsScript);