To Keep It Going, Please Show Your Love.Buy Me a Coffee at ko-fi.com

Runatics

A simple Google analyics component for Svelte Runes project. Please follow the following steps to set it up.

Installation #

pnpm i -D runatics

.env #

Add your ANALYTICS_ID to .env

ANALYTICS_ID="G-12345ABCDE"

+layout.server.js #

Add the following code to +layout.server.js

import { ANALYTICS_ID } from '$env/static/private';
  /** @type {import('./$types').LayoutServerLoad} \*/
export async function load () {
return { ANALYTICS_ID };
}

+layout.svelte #

Add the following code to +layout.svelte

 <script>
  import { Runatics } from 'runatics';
  let { children, data } = $props();
  const analyticsId = data.ANALYTICS_ID
</script>

<Runatics {analyticsId} />

{@render children()}

Technical information about this website