Skip to content

React Installation

Install EventDash in your React application

1
Add the Script Tag
Add the EventDash script to your HTML file (typically public/index.html)
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="root"></div>
  </body>
</html>
2
Automatic Page Views
EventDash automatically tracks the initial page view and SPA route changes. No extra code is required.
javascript
// No additional code required
// Page views are tracked automatically on load and navigation.
3
Track a goal
Prefer trackGoal (or data-ed-goal). Custom track() events need Standard or Pro — see Plans & limits.
javascript
// Component example
function MyComponent() {
  const handleButtonClick = () => {
    if (typeof window !== 'undefined' && window.eventDash) {
      window.eventDash.trackGoal('signup_clicked', {
        buttonId: 'signup-button',
        page: 'homepage'
      })
    }
  }

  return (
    <button onClick={handleButtonClick}>
      Sign Up
    </button>
  )
}
Using HTML Attributes
You can also track events using HTML data attributes without writing JavaScript
jsx
<button data-ed-goal="signup_clicked">
  Sign Up
</button>