Skip to main content
Important: Please ensure your CMP configuration includes new Vendor ID 1469 for 1st Party data tracking. Additionally, include Vendor ID 301 if cookie sync is enabled. Learn more
The setEventProperties method is used to send custom events to Zeotap along with specified event properties and name.

Syntax

Collect.getInstance().setEventProperties(String eventName, Map<String, Object> eventProperties, SDKCallback callback)

Parameters

ParameterTypeRequiredDescription
eventNameStringYesThe name of the event to track
eventPropertiesMap<String, Object>NoKey-value pairs of event properties
callbackSDKCallbackNoCallback function to handle response

Usage Examples

Event Name Only

// Track event with name only
Collect.getInstance().setEventProperties("app_opened");
The payload with event name only:
Event name only in payload
    "events": [
        {
            "event": {
                "eventName": "app_opened",
                "eventTimestamp": 1745959356443
            },
            "user": {
                "zi": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
            },
            "page": { /* ... */ },
            "version": "2.2.8"
        }
    ]

Basic Event Tracking

Map<String, Object> eventProperties = new HashMap<>();
eventProperties.put("product_name", "Wireless Headphones");
eventProperties.put("category", "Electronics");
eventProperties.put("price", 99.99);
eventProperties.put("currency", "USD");

Collect.getInstance().setEventProperties("product_viewed", eventProperties);
The payload with event name and properties:
Event with properties in payload
    "events": [
        {
            "event": {
                "eventName": "product_viewed",
                "product_name": "Wireless Headphones",
                "category": "Electronics",
                "price": 99.99,
                "currency": "USD",
                "eventTimestamp": 1745959356443
            },
            "user": {
                "zi": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
            },
            "page": { /* ... */ },
            "version": "2.2.8"
        }
    ]

Event with Callback

Map<String, Object> eventProperties = new HashMap<>();
eventProperties.put("order_id", "ORD-12345");
eventProperties.put("total_amount", 249.99);

Collect.getInstance().setEventProperties("purchase_completed", eventProperties, (response) -> {
    // Handle success/error response
});

Best Practices

Event Naming

  • Use descriptive, snake_case names: product_viewed, checkout_completed
  • Be consistent across your application
  • Avoid special characters and spaces

Property Structure

// Good: Flat structure with descriptive keys
Map<String, Object> props = new HashMap<>();
props.put("product_id", "PROD-123");
props.put("product_name", "Wireless Mouse");
props.put("category", "Electronics");
props.put("price", 29.99);

For more examples and advanced usage patterns, see our Examples Guide.
Last modified on June 25, 2026