Conversion Tracking
Learn how to track when clicks turn into customers, signups, or any other conversion event.
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
Call
trackConversion()when the user completes a conversion.
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 trackConversion() when a user completes a desired action:
// Basic conversion (no user data)
trackConversion();
// With user data (recommended)
trackConversion({
id: 'user_12345', // Your internal user ID
name: 'John Doe', // User's name
email: '[email protected]', // User's email
metadata: { // Any additional data
plan: 'pro',
value: 99.00
}
});3. Example: After Purchase
// On your checkout success page
document.addEventListener('DOMContentLoaded', function() {
// Assuming you have user data available
trackConversion({
id: currentUser.id,
name: currentUser.name,
email: currentUser.email,
metadata: {
orderId: order.id,
orderValue: order.total
}
});
});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 (<1KB) JavaScript file that:
- Automatically detects
utm_clickparameter in the URL - Stores the click ID in localStorage for persistence
- Provides the global
trackConversion()function - Automatically cleans up after 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",
"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,
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 } = req.body;
await fetch('https://api.gettrack.link/api/conversions', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
click_id: clickId,
user_id: user.id,
name: user.name,
email: user.email,
}),
});
res.json({ success: true });
});Python
import requests
def register_conversion(click_id, user_id=None, name=None, email=None):
response = requests.post(
'https://api.gettrack.link/api/conversions',
json={
'click_id': click_id,
'user_id': user_id,
'name': name,
'email': email,
}
)
return response.json()
# Usage
register_conversion(
click_id='abc123-def456-ghi789',
user_id='user_12345',
name='John Doe',
email='[email protected]'
)Best Practices
- Use the tracking script - It handles edge cases and cleanup automatically.
- 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]