@accuser/svelte-plausible-analytics
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

svelte-plausible-analytics

Add Plausible Analytics to a SvelteKit app and track analytics and custom events.

Important - requires a Plausible Analytics account. All events require custom goals to be configured in the Plausible Analytics dashboard.

Install the package

npm i --save-dev @accuser/svelte-plausible-analytics

Examples

Add Plausible Analytics to the root layout to track page views.

<script>
  import { PlausibleAnalytics } from '@accuser/svelte-plausible-analytics';
</script>

<PlausibleAnalytics />

<slot />

Track analytics events:

<script>
  import { pa } from '@accuser/svelte-plausible-analytics';

  const { login } = pa;
</script>

<button on:click={login('Button')}>Click to login!</button>

Track custom events:

<script>
  import { pa } from '@accuser/svelte-plausible-analytics';

  const { addEvent } = pa;
</script>

<button on:click={addEvent('click')}>Click me!</button>

Contributors

Matthew Gibbons - @accuser

Jeffrey Palmer - @JeffreyPalmer

Dan Grebb - @dgrebb

Package Sidebar

Install

npm i @accuser/svelte-plausible-analytics

Weekly Downloads

148

Version

1.0.0

License

MIT

Unpacked Size

12.8 kB

Total Files

9

Last publish

Collaborators

  • accuser