recordCustomEvent (iOS SDK API)


recordCustomEvent:(NSString*)eventType attributes:(NSDictionary*)attributes;
NewRelic.recordCustomEvent(string $eventType, [string $eventName,] map<string, object> $eventAttributes)

Records a custom mobile monitoring event.


As of New Relic iOS agent version 5.12.0, the recordEvent method is deprecated and replaced with recordCustomEvent. The recordEvent method will continue to work for an unspecified period of time, but if your app contains recordEvent methods, New Relic recommends you replace them.

Updating these methods will affect any queries and that use the deprecated event types. Be sure to adjust your NRQL queries and dashboards as needed.


Creates and records a custom event that you can query using NRQL. The event includes a list of attributes, specified as a map. Unlike using setAttribute, adding attributes to a custom event adds them only to that event; they are not session attributes.

Important considerations and best practices include:

  • Limit the total number of eventType values to approximately five. It is meant to be used for high-level categories, such as Gestures.
  • Do not use eventType to name your custom events. Instead, create attributes to name custom events, or use the optional name parameter.
  • Use the name keyword to display your events in the mobile monitoring UI. To create a useful name, you can combine several attributes. Using the name parameter has the same effect as adding a name key in the attributes dictionary.
  • The elements of the attributes object must be of the type NSString or NSNumber.






Required. The type of event. Do not use $eventType to name your custom events; use a custom attribute or the optional name parameter.



Optional. Use this parameter to name the event. (Using this parameter is equivalent to creating a name parameter.)


map<string, object>

Optional. A map that includes a list of attributes that further designate subcategories to the $eventType. The elements of the attributes object must be of the type NSString or NSNumber.

You can create attributes for any event descriptors you think will be useful. To name your custom events, create a name attribute or use the eventName parameter.


When setting the key for your custom attributes, be aware that there are default attributes that cannot be overridden.

Return values

Returns true if the event is recorded successfully, or false if not.




+ (BOOL) recordCustomEvent:(NSString*)eventType attributes:(NSDictionary*)attributes;
+ (BOOL) recordCustomEvent:(NSString*)eventType name:(NSString*)name attributes:(NSDictionary*)attributes;


BOOL eventRecorded = [NewRelic recordCustomEvent:@"eventType"
attributes:@{@"attributeName1": @"value1", @"attributeName2": @2}];
BOOL eventRecorded = [NewRelic recordCustomEvent:@"Vehicle" name:@"1908 Ford ModelT"
attributes:@{@"make":@"Ford", @"model":@"ModelT", @"year": @1908, @"color": @"black", @"mileage": @250000}];



NewRelic.recordCustomEvent(eventType: String!, attributes:[NSObject : AnyObject]!) -> Bool
NewRelic.recordCustomEvent(eventType: String!, name: String!, attributes:[NSObject : AnyObject]!) -> Bool


let eventRecorded = NewRelic.recordCustomEvent("eventType", attributes: ["attributeName1" : "value1", "attributeName2": 2])
let eventRecorded = NewRelic.recordCustomEvent("Vehicle", name:"1908 Ford ModelT", attributes:["make":"Ford", "model":"ModelT", "year": 1908, "color": "black", "mileage": 250000]);