Integrations: Svelte

Svelte is a lightweight JavaScript framework for building web applications.

Monitor your traffic

Integrating MetricsWave with Svelte is easy. You only need to add the Script inside the <svelte:head> tag.

Something like this is enough.

<svelte:head>
  <!-- MetricsWave Script -->
  <script defer
          event-uuid="00000000-0000-0000-0000-000000000000"
          src="https://tracker.metricswave.com/js/visits.js">
  </script>
</svelte:head>)

It's important that this script should be included on all the pages of your application, maybe you can use a layout or extend the app from this component.

How to trigger events

To trigger events whenever you want you will need to use the API.

You have multiple options to do this, but a simple one it's to create a function like the next and use it everywhere in your application.

You only need to pass the trigger UUID and the parameters of your event.

export function triggerEvent(eventUuid: string, params: Object = {}) {
  if (!app.isProduction) {
    console.log(`[EventTracker] ${eventUuid}`, params)
    return
  }

  fetch(`https://metricswave.com/webhooks/${eventUuid}`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Accept": "application/json",
    },
    body: JSON.stringify(params),
  })
}

← Go back to Documentation

Choose the plan
that fits your needs

Start for free, and upgrade your account at any moment.

All plans include:

  • 100% data ownership
  • Forever data retention
  • No cookie banner required
  • GDPR law compliance
  • Unlimited support
  • Cancel at any time
  • All features available