Event Object

Prev Next

The Event object helps you create custom events and event parameters in different data types. This article explains how you can build events and parameters in various data types.

Set tag event

This method returns a new chainable Insider event object in which you can add parameters. 

Your event name should be lowercase and not include special characters, non-Latin characters, or spaces. Otherwise, this event will be ignored. You can use underscores.
ParameterData Type
eventNameString

Method Signature

public InsiderEvent tagEvent(String eventName)
fun tagEvent(eventName: String): InsiderEvent

Method Example

// You can create an event without parameters and call the build method
Insider.Instance.tagEvent("eventname").build();


// You can create an event, then add parameters and call the build method
Insider.Instance.tagEvent("eventname").addParameterWithInt("key", 10).build();


// You can create an object and add the parameters later
InsiderEvent insiderExampleEvent = Insider.Instance.tagEvent("eventname");


// Do not forget to call build method once you are done with parameters
//Otherwise your event will be ignored
insiderExampleEvent.build();
If you do not call Insider One's Build Event method at the end of the chaining, this method will not function.

Build event

This method allows you to build your Insider event object. 

You need to call this method to trigger your event.

Method Signature

public void build()
fun build()

Method Example

insiderExampleEvent.build();

Set string parameter

This method allows you to set the string parameter of your Insider event object.

Your parameter key should be lowercase and should not include any special character, non-Latin character, or any space. Otherwise, this parameter will be ignored. You can use underscores.
ParameterData Type
keyString
valueString

The value can be up to 50,000 characters. For arrays, the limit applies to each string. An event with a longer value isn't recorded.

Method Signature

public InsiderEvent addParameterWithString(String key, String value)
fun addParameterWithString(key: String, value: String): InsiderEvent

Method Example

// You can create an event then add parameters and call the build method
Insider.Instance.tagEvent("eventname").addParameterWithString("key", "value").build();


// You can create an object and add the parameters later
InsiderEvent insiderExampleEvent = Insider.Instance.tagEvent("eventname");
insiderExampleEvent.addParameterWithString("key", "value");


// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
insiderExampleEvent.build();

Set integer parameter

This method allows you to set the integer parameter of your Insider event object. 

Your parameter key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this parameter will be ignored. You can use underscores.
ParameterData Type
keyString
valueInteger

Method Signature

public InsiderEvent addParameterWithInt(String key, int value)
fun addParameterWithInt(key: String, value: Int): InsiderEvent

Method Example

// You can create an event then add parameters and call the build method
Insider.Instance.tagEvent("eventname").addParameterWithInt("key", 10).build();


// You can create an object and add the parameters later
InsiderEvent insiderExampleEvent = Insider.Instance.tagEvent("eventname");
insiderExampleEvent.addParameterWithInt("key", 10);


// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
insiderExampleEvent.build();
If you do not call Insider One's Build Event method at the end of the chaining, this method will not function.

Set double parameter

This method allows you to set the double parameter of your Insider event object. 

Your parameter key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this parameter will be ignored. You can use underscores.
ParameterData Type
keyString
valueDouble

Method Signature

public InsiderEvent addParameterWithDouble(String key, double value)
fun addParameterWithDouble(key: String, value: Double): InsiderEvent

Method Example

// You can create an event then add parameters and call the build method
Insider.Instance.tagEvent("eventname").addParameterWithDouble("key", 10.5).build();


// You can create an object and add the parameters later
InsiderEvent insiderExampleEvent = Insider.Instance.tagEvent("eventname");
insiderExampleEvent.addParameterWithDouble("key", 10.5);


// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
insiderExampleEvent.build();
If you do not call Insider One's Build Event method at the end of the chaining, this method will not function.

Set date parameter

This method allows you to set the date parameter of your Insider event object. 

Your parameter key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this parameter will be ignored. You can use underscores.
ParameterData Type
keyString
valueDate

Method Signature

public InsiderEvent addParameterWithDate(String key, Date value)
fun addParameterWithDate(key: String, value: Date): InsiderEvent

Method Example

Date date = new Date();


// You can create an event then add parameters and call the build method
Insider.Instance.tagEvent("eventname").addParameterWithDate("key", date);.build();


// You can create an object and add the parameters later
InsiderEvent insiderExampleEvent = Insider.Instance.tagEvent("eventname");
insiderExampleEvent.addParameterWithDate("key", date);


// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
insiderExampleEvent.build();
If you do not call Insider One's Build Event method at the end of the chaining, this method will not function.

Set array of string parameter

This method allows you to set the array of string parameter of your Insider event object. 

Your parameter key should be lowercase and should not include any special character, non-Latin character, or any space. Otherwise, this parameter will be ignored. You can use underscores.
You can call this method only with an array of string. Otherwise, this parameter will be ignored.
ParameterData Type
keyString
valueArray (of string)

The value can be up to 50,000 characters. For arrays, the limit applies to each string. An event with a longer value isn't recorded.

Method Signature

InsiderEvent addParameterWithStringArray(String key, String[] values)
fun addParameterWithStringArray(key: String, values: Array<String>): InsiderEvent

Method Example

String[] stringArray = new String[]{"value1", "value2", "value3"};
Insider.Instance.tagEvent("eventName")
    .addParameterWithStringArray("key", stringArray)
    .build();
If you do not call Insider One's Build Event method at the end of the chaining, this method will not function.

Set array of number parameter

This method allows you to set the array of number parameter of your Insider event object. 

Your parameter key should be only numbers. Otherwise, this parameter will be ignored.
You can call this method only with an array of string. Otherwise this parameter will be ignored.
ParameterData Type
keyNumber
valueArray (of number)

Method Signature

InsiderEvent addParameterWithNumericArray(String key, Number[] values)
fun addParameterWithNumericArray(key: String, values: Array<Number>): InsiderEvent

Method Example

Number[] numberArray = new Number[]{5, 3.14, 100};

Insider.Instance.tagEvent("eventName")
    .addParameterWithNumericArray("key", numberArray)
    .build();
If you do not call Insider One's Build Event method at the end of the chaining, this method will not function.

Set boolean parameter

This method allows you to set the boolean parameter of your Insider event object. 

Your parameter key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this parameter will be ignored. You can use underscores.
ParameterData Type
keyString
valueBoolean

Method Signature

public InsiderEvent addParameterWithBoolean(String key, boolean value)
fun addParameterWithBoolean(key: String, value: Boolean): InsiderEvent

Method Example

// You can create an event then add parameters and call the build method
Insider.Instance.tagEvent("eventname").addParameterWithBoolean("key", true).build();


// You can create an object and add the parameters later
InsiderEvent insiderExampleEvent = Insider.Instance.tagEvent("eventname");
insiderExampleEvent.addParameterWithBoolean("key", true);


// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
insiderExampleEvent.build();
If you do not call Insider One's Build Event method at the end of the chaining, this method will not function.

Set array of objects parameter

This method allows you to set the Array of Objects parameter of your Insider event object. Create the parameter first, as described in Create the Array of Objects Event Parameter. The SDK never creates or changes the parameter definition. The SDK ignores keys not defined in the panel, and the call still succeeds.

  • The parameter key and every key inside the objects must be lowercase, with no special or non-Latin characters. Other keys are ignored.
  • Data that breaks a limit is dropped before sending, and each drop is logged. This covers key naming, strings longer than 500 characters, more than two nesting levels, an Array of Objects inside an object, arrays with mixed item types, and too many keys per object.
  • The object and key limits come from your account settings. Without them, the SDK uses 50 objects and 20 keys per object.
ParameterData TypeDescription
keyStringName of the Array of Objects event parameter.
objectsList<Map<String, Object>>Objects to send with the event.

Method Signature

public InsiderEvent addParameterWithObjectArray(String key, List<Map<String, Object>> objects)
fun addParameterWithObjectArray(key: String, objects: List<Map<String, Any>>): InsiderEvent

Method Example

import com.useinsider.insider.InsiderEvent;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

void sendCartEvent(InsiderEvent event) {
    Map<String, Object> product = new HashMap<>();
    product.put("sku", "p100");
    product.put("quantity", 2);

    List<Map<String, Object>> products = new ArrayList<>();
    products.add(product);

    event.addParameterWithObjectArray("products", products).build();
}
import com.useinsider.insider.InsiderEvent

fun sendCartEvent(event: InsiderEvent) {
    val products = listOf(
        mapOf<String, Any>("sku" to "p100", "quantity" to 2)
    )
    event.addParameterWithObjectArray("products", products).build()
}
Array of Objects event parameters are insert-only, so you cannot update them later. Calling the method again with the same key replaces the earlier list. Invalid objects are dropped one by one, and the call still succeeds. A null or empty list does nothing.
If the list has more objects than the object limit, the SDK logs a warning and still sends it. Trim long lists before you call the method.

Set multiple parameter

This method allows you to set more than one parameter of your Insider event object at a time. 

ParameterData Type
parameters

Map<String, ?>

Method Signature

public InsiderEvent addParameters(Map<String, ?> parameters)
fun addParameters(parameters: Map<String, *>): InsiderEvent

Method Example

String[] array = new String[3];

array[0] = "item1";
array[1] = "item2";
array[2] = "item3";

Map<String, Object> parameters = new HashMap<>();

parameters.put("tag_array", array);
parameters.put("tag_bool", true);
parameters.put("tag_double", 22.2);
parameters.put("tag_string", "insider");
parameters.put("tag_date", new Date());
parameters.put("tag_int", 122);

Insider.Instance.tagEvent("test_event").addParameters(parameters).build();