Skip to content
Start in Cloud

Custom Events

Your tracking script captures page views automatically, but you need to measure specific interactions: a purchase, a video play, a form submission. HitKeep’s custom event API lets you record any named action from the browser or from your server.

If you only need baseline browser interactions such as outbound links, file downloads, or form submits, start with Automatic Events. The default tracker already emits outbound_click, file_download, and form_submit without manual window.hk.event() calls.

For how hk.js sends payloads, retries failed delivery, handles SPA navigation, and limits browser storage, see Tracker Architecture.

Use specific event names that describe the business action. Keep properties small, structured, and free of secrets, raw prompts, form field values, and access tokens.

WorkflowExample event namesTypical path
Signupsignup_started, signup_completedBrowser or server-side event
Leadsdemo_requested, contact_form_submittedBrowser or server-side event
Downloadswhitepaper_downloaded, release_downloadedBrowser event when automatic file_download is not specific enough
Ecommerceview_item, add_to_cart, begin_checkout, purchaseBrowser or server-side event
Assistantsassistant.chat_started, assistant.message_sent, assistant.goal_assistedBrowser or server-side event

For canonical event, export, storage, and runtime facts, see Facts and Limits.

The hk.js tracking snippet exposes window.hk.event():

<script>
// Record a named event with optional properties
window.hk?.event?.('signup', { plan: 'pro' });
</script>

Call this anywhere in your page JavaScript: button click handlers, form submit callbacks, pricing interactions, onboarding steps, or other product-specific actions.

<button onclick="window.hk?.event?.('cta_clicked', { location: 'hero' })">
Get Started
</button>

Send events from your backend when the server confirms the action or when you need to preserve a historical timestamp. Common examples include purchase confirmations, webhook processing, trial starts, account upgrades, and replayed events from logs.

Use the trusted server-side event API with an API client token:

The url field should reflect the page where the event conceptually occurred. HitKeep uses it for site resolution and session context.

Events become useful when combined with Goals. Create an event-based goal to count conversions:

API reference:

The goal value must match the event name exactly. Once created, the dashboard shows conversion counts and timeseries data for that event.

If you are instrumenting an on-site chatbot, keep the event names predictable so the dedicated AI chatbot dashboard can aggregate them automatically.

Recommended event names:

  • assistant.chat_started
  • assistant.message_sent
  • assistant.response_rendered
  • assistant.citation_clicked
  • assistant.handoff_requested
  • assistant.goal_assisted

Recommended properties include:

  • bot_id, provider, model, surface
  • conversation_id, message_index, intent
  • response_ms, tool_count, citation_count
  • goal_name, goal_value

Use structured metadata rather than raw prompt bodies whenever possible. That keeps storage leaner and avoids collecting sensitive conversation text by default.

For a complete walkthrough, see AI Chatbot Analytics.

  1. Emit events using either method above.
  2. Open your site in the dashboard.
  3. Navigate to Goals and create a new Event goal using the event name.
  4. The goal will appear in KPIs, charts, and the Goals timeseries.

Custom events share the ingest endpoint’s rate limiter. The default is 20 requests/sec per IP with a burst of 40. Adjust via configuration if sending high-volume server-side events from a single IP:

FlagEnv VariableDefault
--ingest-rate-limitHITKEEP_INGEST_RATE_LIMIT20.0
--ingest-burstHITKEEP_INGEST_BURST40

See Configuration Reference for all options.

Need event streaming or real-time webhooks on top of custom events? Start with HitKeep Cloud →