← Files FingerprintARCHIVED FILE

skills/fingerprint-tagging/snippets/identify-with-tag.jsx

908 Bytes · Oct 3, 2026 · 06:27 UTC

↓ Download file

// Client — attach your data to the identification at the moment of a sensitive action.
// `tag` is free-form context; `linkedId` groups related events. Both are optional.
import { useVisitorData } from '@fingerprint/react'

export function CheckoutButton({ userId, orderId }) {
  const { getData, isLoading } = useVisitorData({ immediate: false })

  async function onCheckout() {
    const { event_id } = await getData({
      tag: { action: 'checkout', orderId },
      linkedId: `user_${userId}`, // opaque id only — never an email/token
    })

    // Send the event_id to your backend; the tag + linkedId travel with the event server-side.
    await fetch('/api/checkout', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ eventId: event_id, orderId }),
    })
  }

  return <button onClick={onCheckout} disabled={isLoading}>Pay</button>
}

SHA-256: a015bda1f39e9a3ce5de1ef8e26442afb23d75e683a7c77733dcccaa44ce42e3