Clickport
Start free trial

Custom Events

Custom events let you track any user action that matters to your business. Signups, purchases, video plays, button clicks, file downloads, or anything else you want to measure. You define the event name, attach optional properties, and optionally include revenue data.

Custom events are sent using the clickport.track() JavaScript API, which is available automatically on any page where the Clickport tracker is installed.

The clickport.track() API

The tracker exposes a global clickport.track() function with three parameters:

clickport.track(name, properties, revenue)
No setup required. The clickport.track() function is available globally as soon as the Clickport tracker script loads. You do not need to import or initialize anything.

Basic usage

At its simplest, call clickport.track() with just an event name:

JavaScript
// Simple event (name only) clickport.track('Signup'); // Event with properties clickport.track('Signup', { plan: 'pro', source: 'homepage' }); // Event with properties and revenue clickport.track('Purchase', { product: 'Widget', category: 'Electronics' }, { amount: 49.99, currency: 'USD' });

Tracking a button click

<button onclick="clickport.track('CTA Click', { button: 'hero-signup' })">
  Get Started
</button>

Tracking a form submission

document.getElementById('signup-form').addEventListener('submit', function() {
  clickport.track('Form Submit', { form: 'newsletter' });
});

Tracking with a framework (React, Vue, etc.)

// React example
function handlePurchase(product) {
  window.clickport.track('Purchase', {
    product: product.name,
    category: product.category
  }, {
    amount: product.price,
    currency: 'EUR'
  });
}
Tip: In React, Vue, and other frameworks, use window.clickport.track() since the tracker attaches to the global window object.

Properties

Properties let you attach structured data to an event. Pass them as a plain JavaScript object in the second parameter. Each key becomes a property name, and each value becomes the property value.

clickport.track('Video Play', {
  title: 'Product Demo',
  duration: '3:24',
  autoplay: 'false'
});

Properties appear in the dashboard as expandable rows under each event name. You can see which property values are most common and how many times each was recorded.

Property limits

Revenue tracking

The third parameter lets you attach revenue data to any custom event. This is useful for tracking purchases, donations, subscriptions, or any action with a monetary value.

Revenue tracking examples
// Purchase with USD (default currency) clickport.track('Purchase', { product: 'Annual Plan' }, { amount: 199.00 }); // Purchase with a different currency clickport.track('Purchase', { product: 'Monthly Plan' }, { amount: 19.99, currency: 'EUR' }); // Revenue without properties (pass null) clickport.track('Donation', null, { amount: 25 });

The revenue object accepts two fields:

No properties needed. If you want to track revenue without properties, pass null as the second argument: clickport.track('Donation', null, { amount: 25 }).

Custom events in the dashboard

Custom events appear in the Goals panel under the Events tab. Each unique event name is listed as a row with the total count for the selected date range. Click the arrow next to an event name to expand it and see property breakdowns.

Pages Sessions Goals
Goals Outbound Events
Event Count
Purchase 284
product: Annual Plan 162
product: Monthly Plan 98
product: Widget 24
Signup 157
Video Play 93
CTA Click 68

In this example, the "Purchase" event has been expanded to show property breakdowns. The other events show a collapsed arrow, indicating they also have properties you can explore.

Clickport automatically detects new event names as they arrive. There is no setup needed in the dashboard to start seeing your events. Just call clickport.track() and the event will appear in the Events tab.

Using custom events with goals

You can create goals that trigger on custom events. This lets you track conversion rates, compare periods, and see custom events reflected in your KPIs.

To set up a custom event goal, go to Settings > Goals and create a new goal with the type set to Custom Event. Enter the event name exactly as you pass it to clickport.track().

Create Goal
Track conversions based on custom events
Goal Type
Custom Event
Event Name
Purchase
Goal Name (display label)
Completed Purchase

Save Goal

Once configured, the goal appears in the Goals sub-tab with a conversion count and rate. Custom event goals also feed into the Conversions and Conv. Rate KPIs at the top of the dashboard.

Exact match. The event name in the goal configuration must match exactly what you pass to clickport.track(). If you track 'Purchase' in your code, enter Purchase in the goal settings. Matching is case-sensitive.

How it works under the hood

When you call clickport.track(), the tracker sends a lightweight request to the Clickport API. The event is stored with your session data and linked to the current page visit. Here is what gets sent:

Custom events use beacon mode (fetch with keepalive: true) for reliability. This ensures events are delivered even if the user navigates away immediately after the action.

Limits and best practices

Property limits apply per event. Each event can have at most 30 properties. Values longer than 2,000 characters are truncated. Plan your property structure accordingly.

Debugging

To verify your custom events are being sent, open your browser's developer tools and check the Network tab. Filter for requests to /api/event. You should see a POST request with the event data in the request body.

Look for these fields in the payload:

Events appear in the dashboard within a few seconds of being sent. If you do not see your event in the Events tab, check that the tracker script is loaded and that the event name matches what you expect.