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 should not include any special character, non-Latin character, or any space. Otherwise, this event will be ignored. You can use underscores.
ParameterData Type
eventNameString

Method Signature

+(InsiderEvent *)tagEvent:(NSString *)eventName;

Method Examples

// You can create an event without parameters and call the build method
[[Insider tagEvent:@"eventname"] build];


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


// You can create an object and add the parameters later
InsiderEvent *insiderExampleEvent = [Insider tagEvent:@"eventname"];


// Do not forget to call build method once you are done with parameters
// Otherwise your event will be ignored
[insiderExampleEvent build];
// You can create an event without parameters and call the build method
Insider.tagEvent("eventname")?.build()


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


// You can create an object and add the parameters later
var insiderexampleEvent = Insider.tagEvent("eventname")?.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 don't call Insider One's Build Event method at the end of the chaining, this method won't 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

-(void)build;

Method Examples

[insiderExampleEvent build];
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 characters, non-Latin characters, or any spaces. 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

-(InsiderEvent*(^)(NSString *, NSString *))addParameterWithString;

Method Examples

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


// You can create an object and add the parameters later
InsiderEvent *insiderExampleEvent = [Insider 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];
// You can create an event then add parameters and call the build method
Insider.tagEvent("eventname")?.addParameterWithString()("key", "value")?.build()


// You can create an object and add the parameters later
var insiderexampleEvent = Insider.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

-(InsiderEvent*(^)(NSString *, int))addParameterWithInt;

Method Examples

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


// You can create an object and add the parameters later
InsiderEvent *insiderExampleEvent = [Insider 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];
// You can create an event then add parameters and call the build method
Insider.tagEvent("eventname")?.addParameterWithInt()("key", 10)?.build()


// You can create an object and add the parameters later
var insiderexampleEvent = Insider.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'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

-(InsiderEvent*(^)(NSString *, double))addParameterWithDouble;

Method Examples

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


// You can create an object and add the parameters later
InsiderEvent *insiderExampleEvent = [Insider 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];
// You can create an event then add parameters and call the build method
Insider.tagEvent("eventname")?.addParameterWithDouble()("key", 10.5)?.build()


// You can create an object and add the parameters later
var insiderexampleEvent = Insider.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'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

-(InsiderEvent*(^)(NSString *, NSDate *))addParameterWithDate;

Method Examples

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


// You can create an object and add the parameters later
InsiderEvent *insiderExampleEvent = [Insider tagEvent:@"eventname"];
insiderExampleEvent.addParameterWithDate(@"key", [NSDate date]);


// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
[insiderExampleEvent build];
// You can create an event then add parameters and call the build method
Insider.tagEvent("eventname")?.addParameterWithDate()("key", Date())?.build()


// You can create an object and add the parameters later
var insiderexampleEvent = Insider.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 don't call Insider One's Build Event method at the end of the chaining, this method won't 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 * (^)(NSString *key, NSArray<NSString *> *value))addParameterWithStringArray

Method Examples

// You can create an event then add parameters and call the build method
[[Insider tagEvent:@"eventName"].addParameterWithStringArray(@"key", @[@"value1", @"value2", @"value3"]) build];

// You can create an object and add the parameters later
InsiderEvent *insiderExampleEvent = [Insider tagEvent:@"eventName"];
insiderExampleEvent.addParameterWithStringArray(@"key", @[@"value1", @"value2", @"value3"]);

// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
[insiderExampleEvent build];
// You can create an event then add parameters and call the build method
Insider.tagEvent("eventName")
    .addParameterWithStringArray()("key", ["value1", "value2", "value3"])
    .build()

// You can create an object and add the parameters later
let insiderExampleEvent = Insider.tagEvent("eventName")
insiderExampleEvent?.addParameterWithStringArray()("key", ["value1", "value2", "value3"])

// 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'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 number. Otherwise this parameter will be ignored.
ParameterData Type
keyNumber
valueArray (of number)

Method Signature

- (InsiderEvent * (^)(NSString *key, NSArray<NSNumber *> *value))addParameterWithNumericArray;

Method Examples

// You can create an event then add parameters and call the build method
[[Insider tagEvent:@"eventName"].addParameterWithNumericArray(@"key", @[@5, @3.14, @100]) build];

// You can create an object and add the parameters later
InsiderEvent *insiderExampleEvent = [Insider tagEvent:@"eventName"];
insiderExampleEvent.addParameterWithNumericArray(@"key", @[@5, @3.14, @100]);

// Do not forget to call build method once you are done with parameters.
// Otherwise your event will be ignored.
[insiderExampleEvent build];
// You can create an event then add parameters and call the build method
Insider.tagEvent("eventName")
    .addParameterWithNumericArray()("key", [5, 3.14, 100])
    .build()

// You can create an object and add the parameters later
let insiderExampleEvent = Insider.tagEvent("eventName")
insiderExampleEvent?.addParameterWithNumericArray()("key", [5, 3.14, 100])

// 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'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

-(InsiderEvent*(^)(NSString *, bool))addParameterWithBoolean;

Method Examples

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


// You can create an object and add the parameters later
InsiderEvent *insiderExampleEvent = [Insider 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];
// You can create an event then add parameters and call the build method
Insider.tagEvent("eventname")?.addParameterWithBoolean()("key", true)?.build()


// You can create  an object and add the parameters later
var insiderexampleEvent = Insider.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's Build Event method at the end of the chaining, this method will not function.

Add an array-of-objects event parameter

Use Array of Objects event parameters to send a list of structured objects with an event. Define the parameter and its structure in the Insider One panel first: keys that are not registered there are dropped when the data is received, while the request still succeeds.

Call addParameterWithObjectArray on an event to attach a list of objects as one parameter. These parameters are insert-only: they cannot be updated later or used as a filter. To define the parameter in the panel, see Create the Array of Objects Event Parameter.

ParameterData TypeDescription
keyNSStringName of the event parameter. Lowercase, with no special or non-Latin characters.
valueNSArray<NSDictionary *>Objects to send with the event.

Method Signature

- (InsiderEvent * (^)(NSString *key, NSArray<NSDictionary *> *value))addParameterWithObjectArray;
func addParameterWithObjectArray() -> (String, [[AnyHashable: Any]]) -> InsiderEvent

Method Examples

[[Insider tagEvent:@"checkout"].addParameterWithObjectArray(@"items", @[
    @{@"sku": @"a100", @"quantity": @2},
    @{@"sku": @"b200", @"quantity": @1}
]) build];
Insider.tagEvent("checkout").addParameterWithObjectArray()("items", [
    ["sku": "a100", "quantity": 2],
    ["sku": "b200", "quantity": 1]
]).build()

The SDK checks every object before sending. Anything that fails a rule is dropped with a console warning; no error is thrown.

  • Keys must be lowercase, with no special or non-Latin characters.
  • String values can be up to 500 characters.
  • Objects nest at most two levels and cannot contain an array of objects.
  • Array values must be non-empty lists of strings or numbers, all of one type.
  • An invalid parameter key drops the whole parameter. An invalid key inside an object drops only that key.
  • An object with more keys than the per-object limit is dropped whole.

Set multiple parameters

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

ParameterData Type
parameters

 NSDictionary

Method Signature

-(InsiderEvent*(^)(NSDictionary *))addParameters;

Method Examples

NSArray *array = @[@"item1", @"item2", @"item3"];

NSMutableDictionary *parameters = [NSMutableDictionary dictionary];

[parameters setObject:array forKey:@"tag_array"];
[parameters setObject:@(YES) forKey:@"tag_bool"];
[parameters setObject:@(22.2) forKey:@"tag_double"];
[parameters setObject:@"insider" forKey:@"tag_string"];
[parameters setObject:[NSDate date] forKey:@"tag_date"];
[parameters setObject:@(122) forKey:@"tag_int"];

InsiderEvent *event = [Insider tagEvent:@"test_event"];

event.addParameters(parameters);

[event build];
let array: [String] = ["item1", "item2", "item3"]

var parameters: [String: Any] = [:]

parameters["tag_array"] = array
parameters["tag_bool"] = true
parameters["tag_double"] = 22.2
parameters["tag_string"] = "insider"
parameters["tag_date"] = Date()
parameters["tag_int"] = 122

let event = Insider.tagEvent("test_event")

event?.addParameters()(parameters)

event?.build()