Conversion Tracking
Learn how to track when clicks turn into customers, signups, or any other conversion event — and attach the revenue behind each one so Track Link can compute ROI and ROAS for your campaigns.
Overview
Conversion tracking allows you to measure the effectiveness of your links by tracking when users complete desired actions (purchases, signups, form submissions, etc.) after clicking your tracked links.
How It Works
- User clicks your tracked link
A unique
utm_clickparameter is added to your destination URL automatically. - Track Link script captures it
Our lightweight tracking script automatically stores the click ID in localStorage.
- Register the conversion (with revenue)
Call
track()when the user completes a conversion, passing the order value so we can attribute revenue back to the link and campaign.
Quick Start (Recommended)
The easiest way to implement conversion tracking is using our tracking script. Add this snippet to your website:
1. Add the Tracking Script
Add this script to every page of your website (ideally in the <head>):
<script src="https://api.gettrack.link/t.js" data-api="https://api.gettrack.link"></script>
2. Track Conversions
Call track(eventType, details) when a user completes a desired action. Pass a value on revenue-generating events (like sales) so Track Link can roll up revenue, ROI and ROAS:
// A sale, with revenue (powers ROI / ROAS)
track('sale', {
value: 49.99, // Order total
currency: 'USD', // ISO code (defaults to USD)
event_name: 'Checkout' // Optional label
});
// A lead / signup (no monetary value)
track('lead', {
event_name: 'Newsletter signup'
});
// You can also attach the user who converted
track('sale', {
value: 49.99,
currency: 'USD',
event_name: 'Checkout',
id: 'user_12345', // Your internal user ID
name: 'John Doe',
email: '[email protected]',
metadata: { orderId: 'ord_987', plan: 'pro' }
});3. Example: After Purchase
// On your checkout success page
document.addEventListener('DOMContentLoaded', function() {
track('sale', {
value: order.total, // The revenue for this conversion
currency: order.currency, // e.g. 'USD'
event_name: 'Checkout',
id: currentUser.id,
name: currentUser.name,
email: currentUser.email,
metadata: { orderId: order.id }
});
});Backward compatible: trackConversion() still works exactly as before, and value is always optional — omit it for leads and signups.
That's it! The script automatically captures the click ID from the URL and cleans up after a successful conversion.
How the Script Works
The tracking script (t.js) is a lightweight, dependency-free (<2KB) JavaScript file that:
- Automatically detects the
utm_clickparameter in the URL - Stores the click ID in localStorage for persistence
- Provides the global
track()andtrackConversion()functions - Reports conversion
valueandcurrencyso revenue, ROI and ROAS roll up automatically - Automatically cleans up after a successful conversion
- Handles errors gracefully without breaking your site
Manual Implementation
If you prefer not to use our script, you can implement conversion tracking manually.
API Endpoint
POST https://api.gettrack.link/api/conversionsRequest Body
{
"click_id": "abc123-def456-ghi789",
"value": 49.99, // Optional - revenue for this conversion
"currency": "USD", // Optional - ISO code, defaults to USD
"event_type": "sale", // Optional - "sale" | "lead" | "signup" | custom
"event_name": "Checkout", // Optional - human label
"user_id": "user_12345", // Optional
"name": "John Doe", // Optional
"email": "[email protected]", // Optional
"host": "yoursite.com", // Optional
"page_url": "https://yoursite.com/success", // Optional
"metadata": { "plan": "pro" } // Optional
}Response
{
"success": true,
"conversion": {
"id": "conv_123",
"click_id": "abc123-def456-ghi789",
"created_at": "2025-12-17T10:30:00Z"
}
}Manual JavaScript Example
Capture the click ID and register conversions manually:
// 1. Capture click_id on page load
const urlParams = new URLSearchParams(window.location.search);
const clickId = urlParams.get('utm_click');
if (clickId) {
localStorage.setItem('link_track_id', clickId);
}
// 2. Register conversion when needed
async function registerConversion(userData) {
const clickId = localStorage.getItem('link_track_id');
if (!clickId) return;
try {
const response = await fetch('https://api.gettrack.link/api/conversions', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
click_id: clickId,
value: userData?.value, // Optional - revenue for ROI / ROAS
currency: userData?.currency, // Optional - defaults to USD
event_type: userData?.eventType,
event_name: userData?.eventName,
user_id: userData?.id,
name: userData?.name,
email: userData?.email,
host: window.location.hostname,
page_url: window.location.href
}),
});
if (response.ok) {
localStorage.removeItem('link_track_id');
}
} catch (error) {
console.error('Conversion tracking failed:', error);
}
}Server-Side Examples
Node.js / Express
app.post('/checkout/success', async (req, res) => {
const { clickId, user, order } = req.body;
await fetch('https://api.gettrack.link/api/conversions', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
click_id: clickId,
value: order.total, // Revenue for ROI / ROAS
currency: order.currency, // e.g. 'USD'
event_type: 'sale',
event_name: 'Checkout',
user_id: user.id,
name: user.name,
email: user.email,
}),
});
res.json({ success: true });
});Python
import requests
def register_conversion(click_id, value=None, currency=None,
event_type=None, event_name=None,
user_id=None, name=None, email=None):
response = requests.post(
'https://api.gettrack.link/api/conversions',
json={
'click_id': click_id,
'value': value, # Optional - revenue for ROI / ROAS
'currency': currency, # Optional - defaults to USD
'event_type': event_type,
'event_name': event_name,
'user_id': user_id,
'name': name,
'email': email,
}
)
return response.json()
# A sale, with revenue
register_conversion(
click_id='abc123-def456-ghi789',
value=49.99,
currency='USD',
event_type='sale',
event_name='Checkout',
user_id='user_12345',
name='John Doe',
email='[email protected]'
)
# A lead, no value
register_conversion(
click_id='abc123-def456-ghi789',
event_type='lead',
event_name='Demo request'
)Best Practices
- Use the tracking script - It handles edge cases and cleanup automatically.
- Send revenue on sales - Pass
value(andcurrency) on purchases so Track Link can compute ROI and ROAS for each campaign. Leave it off for leads and signups. - Include user data when possible - This helps you identify which users converted.
- Track meaningful conversions - Focus on actions that matter (purchases, signups, not page views).
- Test in development - Verify conversions are being tracked before going live.
- Server-side for critical conversions - For purchases, consider server-side tracking as a backup.
Viewing Conversions
Once conversions are registered, you can view them in your dashboard:
- Go to the Links page and click on a specific link
- The link details page shows conversion count and rate
- Click on individual clicks to see associated conversion data
Need Help?
If you have questions about implementing conversion tracking, please contact us at [email protected]