Custom Events allow your app developers to programmatically trigger inserts and/or send analytics data to the Insert cloud service. To use custom events in Insert, you need to both define the events in the console and place code in your app to trigger the events. Custom events can be used by hybrid apps to trigger inserts by actions happening in the HTML part of the app, for more info read here.
The first step is to define the events in the Insert Console. On the main dashboard click Apps and then select your app. Click Custom Events in the menu on the left side of the screen, and then select the correct application version.
Press New Event to create a new event, and provide the necessary information per the dialog.
You can view and manage your custom events from the Insert Console.
The custom events view in the Insert Console provides the required Android or iOS code to add to your app. Simply copy the code and insert it into your app code as desired. Note that custom events parameters are currently not supported.
The code should look as follows:
|Android||HashMap<String, String> params = new HashMap<String, String>();
|Objective-C||NSDictionary<NSString *, NSString *> *params = [NSDictionary new];
params[@"Name"] = @"John";
[[InsertManager sharedManager] eventOccurred:@"loggedIn" params:params];
|Swift||var params: Dictionary<String, String> = Dictionary();
params["Name"] = "John";
After defining custom events in the Insert Console and placing the appropriate code in your app, you can use any event as a trigger for an insert. To use a custom event as a trigger, simply choose the Custom Event option on the Triggers page of the insert creation wizard. Then, choose from any of the custom events that you have defined for the target app in the Insert Console.
You can also use custom event occurrence or non-occurrence as part of the definition of a mobile segment. To do so, click on the App Activity section of the mobile segment dialog. After enabling app activity segmentation, select Custom Event from the activity type dropdown.
Next select the event for which you want to build a rule, and specify the desired conditions for the rule.
You can use as many different custom events as you want in the mobile segment definition.