Tragly Documentation
Managed server-side tracking for GA4, Facebook CAPI, TikTok, and webhooks. No servers to manage — just paste a script tag and configure your integrations.
Quick Start
- Sign up for a Tragly account
- You'll receive a tracking ID (e.g.
TRG-0001) - Add the tracking script to your website (see below)
- Configure your integrations (GA4, Facebook, etc.) in the dashboard
- Data starts flowing immediately
Add the Tracking Script
Add this snippet to your site's <head> tag. Replace the tracking ID with the one from your dashboard.
<!-- Tragly tracking script -->
<script src="https://track.tragly.com/t.js" data-id="TRG-0001" defer></script>
Or use the async loader for more control:
<script>
(function(t,r,a,g,l,y){
t.tragly=t.tragly||function(){(t.tragly.q=t.tragly.q||[]).push([].slice.call(arguments))};
l=r.createElement(a);y=r.getElementsByTagName(a)[0];
l.async=1;l.src=g;y.parentNode.insertBefore(l,y)
})(window,document,'script','https://track.tragly.com/t.js');
tragly('init', 'TRG-0001');
</script>
Auto-tracked events
| Event | Trigger | Params |
|---|---|---|
page_view | On page load | page_url, path, referrer |
session_start | New session (30min timeout) | new_session: true |
scroll_depth | 25%, 50%, 75%, 100% | scroll_percent |
time_on_page | Every 5 seconds | engagement_time_msec |
outbound_click | Click on external link | href |
Custom Events
// Track a purchase
tragly('event', 'purchase', {
value: 49.99,
currency: 'EUR',
item_name: 'Pro Plan'
});
// Track a form submission
tragly('event', 'lead', {
form_id: 'contact-form'
});
GA4 Setup
Tragly forwards your events to GA4 using the Measurement Protocol. To connect:
- In GA4, go to Admin → Data Streams → your stream
- Under Measurement Protocol API secrets, create a new secret
- Copy the Measurement ID (G-XXXXXXX) and API Secret
- Paste them into your Tragly dashboard under Integrations → GA4
Facebook Conversions API
- In Facebook Events Manager, go to Settings → Conversions API
- Generate an access token
- Note your Pixel ID
- Enter both in your Tragly dashboard under Integrations → Facebook
Event name mapping is automatic: page_view → PageView, purchase → Purchase, add_to_cart → AddToCart, lead → Lead. User data (email, phone) is SHA-256 hashed before sending.
TikTok Events API
- In TikTok Ads Manager, go to Assets → Events → Web Events
- Create a pixel and generate an access token
- Enter the pixel code and token in your Tragly dashboard under Integrations → TikTok
Event mapping: page_view → ViewContent, purchase → CompletePayment, add_to_cart → AddToCart, lead → SubmitForm.
Webhooks
Forward events to any HTTP endpoint. Configure webhooks in the dashboard under Integrations → Webhooks.
Each webhook payload is signed with HMAC-SHA256. Verify the signature on your end:
const expected = crypto.createHmac('sha256', secret)
.update(rawBody).digest('hex');
const valid = req.headers['x-tragly-signature'] === expected;
Dashboard Overview
Your dashboard shows:
- Pageviews, unique visitors, sessions, and average engagement time
- Event breakdown by type
- Time-series charts (daily/hourly)
- Recent event log with full parameters
Use the date range selector to filter by today, 7 days, or 30 days.
Real-Time View
The real-time view shows live data as it arrives:
- Active visitors right now
- Most active pages
- Live event feed with country, page, and event type
Billing & Plans
| Plan | Events/month | Tracking IDs | Price |
|---|---|---|---|
| Starter | 10,000 | 1 | €29/mo |
| Pro | 100,000 | 5 | €79/mo |
| Enterprise | Unlimited | Unlimited | €199/mo |
Manage your subscription in the billing page. You'll see a usage bar showing how many events you've used this month. We'll notify you at 80% usage.
POST /track
Send a single event. The tracking script uses this automatically, but you can also call it from your backend for server-to-server tracking.
POST https://track.tragly.com/track
Content-Type: application/json
{
"client_id": "user-uuid",
"tracking_id": "TRG-0001",
"events": [{
"name": "purchase",
"params": {
"value": 49.99,
"currency": "EUR"
}
}]
}
Response
{
"ok": true,
"received": 1,
"forwarded": true
}
POST /track/batch
Same as /track but for sending multiple events at once. Maximum 25 events per request.
GET /collect
Pixel endpoint. Returns a 1x1 transparent GIF. Used by the tracking script as a no-JS fallback.
GET https://track.tragly.com/collect?cid=user-id&tid=TRG-0001&en=page_view
GET /api/events
List stored events. Requires authentication (Bearer token from your dashboard session).
| Param | Type | Description |
|---|---|---|
from | number | Start timestamp (ms) |
to | number | End timestamp (ms) |
event | string | Filter by event name |
limit | number | Max results (default 50, max 500) |
GET /api/stats
Aggregated statistics. Requires authentication.
GET https://track.tragly.com/api/stats?from=1700000000000
{
"ok": true,
"summary": {
"pageviews": 1234,
"users": 456,
"sessions": 789,
"avg_engagement": 3200
}
}