Skip to content

Latest commit

 

History

History
58 lines (37 loc) · 1.16 KB

README.md

File metadata and controls

58 lines (37 loc) · 1.16 KB

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