Vue.js Installation

Install EventDash in your Vue.js application

1
Add the Script Tag
Add the EventDash script to your HTML file (typically public/index.html)
<!-- public/index.html -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <script
      defer
      data-api-key="YOUR_API_KEY"
      src="https://www.eventda.sh/tracker.js"
    ></script>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>
2
Automatic Page Views
EventDash automatically tracks the initial page view and SPA route changes. No extra code is required.
// No additional code required
// Page views are tracked automatically on load and navigation.
3
Track Custom Events
Use the EventDash SDK in your Vue components
<!-- MyComponent.vue -->
<template>
  <button @click="handleClick">Sign Up</button>
</template>

<script setup>
const handleClick = () => {
  if (typeof window !== 'undefined' && window.eventDash) {
    window.eventDash.track('button_clicked', {
      buttonId: 'signup-button',
      page: 'homepage'
    })
  }
}
</script>
Using HTML Attributes
You can also track events using HTML data attributes in your Vue templates
<template>
  <button data-ed-goal="signup_clicked">
    Sign Up
  </button>
</template>