Introduction
Custom events allow you to track events beyond standard e-commerce events. This guide explains how to create and track custom events for your specific business needs.
Note: Custom events work with ServerTrack. You can use any event name and include any parameters that make sense for your tracking needs.
What are Custom Events?
Custom events are events you define for your specific tracking needs:
- Any Event Name: Use any name that describes your event
- Flexible Parameters: Include any parameters relevant to your event
- Business-Specific: Track actions specific to your business
When to Use Custom Events
Use custom events to track:
- Business-Specific Actions: Actions unique to your business
- User Engagement: Video views, downloads, signups, etc.
- App-Specific Events: Events specific to your application
- Conversion Goals: Custom conversion goals beyond purchases
Event Naming Conventions
Best practices for custom event names:
- Descriptive: Use clear, descriptive names
- Consistent: Use consistent naming across your site
- PascalCase or camelCase: Use consistent capitalization
- Avoid Spaces: Don't use spaces in event names
Examples:
VideoPlayNewsletterSignupDownloadPDFContactFormSubmit
Custom Event Structure
Custom events follow the same structure as standard events:
st('track', 'YourCustomEventName', {
// Your custom parameters
custom_param_1: 'value1',
custom_param_2: 'value2',
value: 99.99, // Optional: numeric value
currency: 'USD' // Optional: currency code
}, userData);
Implementation Examples
Example: Video Play
function trackVideoPlay(videoId, videoTitle) {
const userData = {
country: "US"
};
st('track', 'VideoPlay', {
video_id: videoId,
video_title: videoTitle,
content_type: 'video'
}, userData);
}
Example: Newsletter Signup
function trackNewsletterSignup(email) {
const userData = {
em: email,
country: "US"
};
st('track', 'NewsletterSignup', {
content_type: 'newsletter',
method: 'website'
}, userData);
}
Example: File Download
function trackDownload(fileName, fileType) {
const userData = {
country: "US"
};
st('track', 'DownloadPDF', {
file_name: fileName,
file_type: fileType,
content_type: 'download'
}, userData);
}
Parameter Guidelines
For custom event parameters:
- Use Meaningful Names: Parameter names should be descriptive
- Consistent Data Types: Use consistent data types (strings, numbers, arrays)
- Include Value When Relevant: Include value and currency if event has monetary value
- Follow Standards: When possible, use standard parameter names (value, currency, content_type)
Platform Limitations
Consider platform limitations:
- Facebook: Custom events work, but standard events are preferred for optimization
- TikTok: Custom events are supported
- GA4: Custom events are fully supported
Best Practices
- Use Standard Events When Possible: Prefer standard events for common actions
- Clear Naming: Use clear, descriptive event names
- Consistent Parameters: Use consistent parameter names and structures
- Document Your Events: Keep documentation of your custom events
Summary
Custom events allow you to track business-specific actions. Use descriptive names, include relevant parameters, and follow naming conventions. Custom events work across all platforms supported by ServerTrack.