Important: For conversion tracking to work, users must arrive on your
website via a Taapit deeplink. This is how the tracking ID (ta_tid) is
generated and passed to your site.
Before you start:
Create a Taapit deeplink pointing to your website or landing page
Enable conversion tracking on your link:
Go to your link settings in the Taapit dashboard
Enable Conversion Tracking
Then, configure your Taapit workspace:
1
Go to Conversion settings
In your Taapit dashboard, go to Settings →
Conversion 2. In the
dropdown, select Manual Client-side Integration
2
Add your allowed hostnames
In the Allowed Hostnames section, add your website domains (e.g.,
example.com, www.example.com) 2. Click Save
The SDK will only work on domains listed in your allowed hostnames. Don’t
forget to add both www and non-www versions if needed.
3
Get your Publishable Key
Copy your Publishable Key (starts with taapit_pk_) 2. You’ll use
this key in the next steps
If you don’t have a publishable key yet, click Generate Key to create
one.
A lead is a potential customer who shows interest (sign-up, form submission, trial start).
trackingId for leads: The trackingId is always required for lead
events. It is automatically detected from the ta_tid cookie set when the
user clicked a Taapit link.
NPM Package
Script Tag
components/signup-form.tsx
Copy
'use client';import { useTaapitAnalytics } from 'taapit-sdk/react';export function SignUpForm() { const { trackLead, isReady, trackingId } = useTaapitAnalytics();const handleSubmit = async (formData: FormData) => {const email = formData.get('email') as string;const name = formData.get('name') as string; // Create user in your system const user = await createUser({ email, name }); // Track the lead with Taapit trackLead({ customer: { externalId: user.id, // Required: your user ID email: user.email, firstname: user.firstName, lastname: user.lastName, }, metadata: { source: 'signup-form', plan: 'free-trial', }, });};return (<form action={handleSubmit}> <input name="name" placeholder="Name" required /> <input name="email" type="email" placeholder="Email" required /> <button type="submit">Start Free Trial</button></form>); }
A sale is a completed transaction (purchase, subscription, payment).
trackingId for sales: If the customer was already tracked via a lead
event, the trackingId is optional. You only need the customerExternalId
to link the sale to the existing customer. If this is a new customer (no
prior lead), the user must have a valid ta_tid cookie (set by clicking a
Taapit link).
NPM Package
Script Tag
components/checkout.tsx
Copy
'use client';import { useTaapitAnalytics } from 'taapit-sdk/react';export function CheckoutButton({ cart, user }) { const { trackSale } = useTaapitAnalytics();const handlePurchase = async () => {// Process paymentconst order = await processPayment(cart); // Track the sale with Taapit trackSale({ customer: { externalId: user.id, email: user.email, }, amount: cart.total, // e.g., 49.99 (NOT cents) currency: 'eur', // ISO 4217 code metadata: { orderId: order.id, items: cart.items.length, }, }); router.push(`/order/${order.id}`);};return (<button onClick={handlePurchase}>Complete Purchase - €{cart.total}</button>); }
Copy
<script> document.getElementById('checkout-btn').addEventListener('click', async () => { // Process payment via your API const response = await fetch('/api/checkout', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ cartId: 'cart_123' }), }); const order = await response.json(); // Track the sale taapit.trackSale({ customer: { externalId: order.userId, email: order.customerEmail, }, amount: order.total, currency: order.currency, metadata: { orderId: order.id }, }); window.location.href = `/order/${order.id}`; });</script>
The amount must be in currency units, not cents. - ✅ amount: 29.99
for €29.99 - ❌ amount: 2999 (this would be €2999)