Client-side tracking for revenue attribution

While server-side tracking is recommended for accuracy, you can also track revenue directly from the browser. This is useful for quick implementation or when server-side integration isn't possible.

1. Connect your Payment Provider

Go to your website settings in DataFast and follow the steps to connect your Stripe/LemonSqueezy account.

2. Track Revenue Events

Add the following code after successful payments to track revenue:

// Track revenue after successful payment
window.datafast("payment", { email: "chuck@norris.com" });

Pass the actual email of the customer to the payment event.


Example Implementation

Let's say your customers are redirected to a /welcome page after completing a checkout. You want to fire the DataFast payment event on this page. Using React, you can do this like this:

"use client"

import { useEffect } from 'react';

export default function Dashboard({ userData }) {

  useEffect(() => {
    window.datafast("payment", { email: userData.email });
  }, [userData]);

  return (
    <div>
      <h1>Welcome to the app!</h1>
    </div>
  );
}

Important Notes

  • Duplicate payment events are ignored so you don't need to worry about sending multiple events for the same payment
  • For better accuracy, consider using server-side tracking instead
Something missing? Suggest features ✍️