Sending custom events with Hardal Hardal Web SDK provides a flexible way to track custom events through the hardal.track() method.

This guide will show you how to implement custom event tracking for different use cases.

Sending Events

Basic Event Tracking

The simplest form of tracking is sending just an event name:

hardal.track("test_event")

You can run this event both client and server-side

Events with Properties

You can send additional data with your events using the properties parameter:

You can run this event both client and server-side

E-commerce Marketing Event Examples:

For e-commerce websites, you can track detailed purchase information:

Gaming Events Examples:

For gaming applications, track player progress and interactions:

Server-Side Processing

When these events are sent to Hardal, they are automatically enriched with additional information as shown in the data schema:

Server-generated distinct ID

Unique cookieless identifier generated for each session.

Example
hr_1734601539658_5080zh7of

You can enable or disable the SDK from generating identifiers to ensure better compliance with marketing and analytics regulations, such as GDPR, KVKK, or other privacy standards.

Page Information

Details about the current page.

You can enable or disable from SDK. with autoPageView: True // False

Screen and browser details

Device and browser specifications

  • Resolution: 1920x1080

  • Browser: Chrome

  • Version: 131.0.0.0

Device type

Type of device being used (e.g., desktop, mobile, tablet)

Timezone

User’s timezone

Example: Europe/Istanbul

Timestamp

Server event occurrence time

  • 2024-12-19T09:45:39.659Z

Query parameters

Any URL query parameters, including UTMs.

https://example.com/products?utm_source=newsletter&utm_medium=email&utm_campaign=summer_sale&utm_term=discount&utm_content=header_banner&custom_param1=user_tier&custom_param2=region_europe

You can include as many custom parameters as needed to custom your marketing and analytics goals, as long as they don’t conflict with reserved keywords like standard UTM parameters.

Best Practices

  1. Consistent Naming: Use snake_case for event names and properties

  2. Structured Data: Group related properties into nested objects

  3. Data Types: Use appropriate data types (strings, numbers, booleans, arrays)

  4. Timestamp Handling: Include timestamps for time-sensitive events

  5. Validation: Verify all required properties are present before sending