"The only analytics dashboard I open every day"

Add DataEasy to a React or Vite app

For Vite, Create React App and other single-page apps, add the snippet to the <head> of your index.html. Route changes made with React Router (or any router using the History API) are tracked as pageviews automatically.

index.html
<script
  defer
  data-website-id="YOUR_WEBSITE_ID"
  data-domain="yourdomain.com"
  src="https://dataeasy.app/js/script.js"
></script>

Developing locally? The script ignores localhost by default so your dev sessions don't pollute your stats. To test the integration, temporarily add data-allow-localhost="true" and data-debug="true".

Goals from React

function UpgradeButton() {
  return (
    <button onClick={() => window.dataeasy?.("upgrade_clicked", { plan: "pro" })}>
      Upgrade
    </button>
  );
}

// โ€ฆor without any JavaScript:
<button data-dataeasy-goal="upgrade_clicked" data-dataeasy-goal-plan="pro">Upgrade</button>

โœ๏ธ Something missing? Tell us.

๐Ÿงญ New to DataEasy? Start with the introduction