Integrations: React

React is a free, open-source JavaScript library utilized for crafting user interfaces based on components.

Integrating MetricsWave with react it's usually a single line of code.

How to measure your traffic

Inside your index.html file you just need to add the script inside the head tag.

Something like this:

<!DOCTYPE html>
<html lang="en">

<head>
    <!-- Other tags in your file -->


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

</head>

<body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
</body>

</html>

How to measure 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 (!process.env.NODE_ENV === "production") {
        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