---
title: Increment session attribute count
source: https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/mobile-sdk/increment-session-attribute-count
---

## Android

### Syntax [#syntax]

#### Java [#java]

```java
NewRelic.incrementAttribute(string $name[, float $value])
```

#### Kotlin [#kotlin]

```kotlin
NewRelic.incrementAttribute(name: String!, value : Double)
```

### Description [#description]

Increments the count of an attribute. Overwrites its previous value and type each time it is called.

When passed with only a name value, this method increments the count for the specified attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1. When passed an optional float value, it increments the count for the specified attribute by the float value.

### Parameters [#parameters]

| Parameter | Type     | Description                                                 |
| --------- | -------- | ----------------------------------------------------------- |
| `$name`   | `string` | Required. The name of the attribute.                        |
| `$value`  | `float`  | Optional. The attribute is incremented by this float value. |

### Return values [#return-values]

Returns `true` if recorded successfully, or `false` if not.

### Examples [#examples]

Here's an example to increment the count for the specified attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1:

#### Java [#java]

```java
boolean incremented = NewRelic.incrementAttribute("rate");
```

#### Kotlin [#kotlin]

```kotlin
val incremented = NewRelic.incrementAttribute("rate")
```

Here's an example to increment the count for the specified attribute by the float value amount:

#### Java [#java]

```java
boolean incremented = NewRelic.incrementAttribute("rate", 9999.99, false);
```

#### Kotlin [#kotlin]

```kotlin
val incremented: Boolean = NewRelic.incrementAttribute("rate", 9999.99)
```

## iOS

### Syntax [#syntax]

#### Objective-c [#objc]

```objectivec
incrementAttribute:(NSString*)name value:(NSNumber*)amount;
```

#### Swift [#swift]

```swift
NewRelic.incrementAttribute(string $name[, float $value])
```

### Description [#description]

Increments the count of a session attribute. Overwrites previous value and type each time called.

When passed with only a name value, this method increments the count for the specified session attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1. When passed an optional float value, it increments the count for the specified attribute by the float value.

### Parameters [#parameters]

| Parameter | Type     | Description                                         |
| --------- | -------- | --------------------------------------------------- |
| `name`    | `string` | Required. The name of the attribute to increment.   |
| `amount`  | `number` | Optional. The amount to increment the attribute by. |

### Return values [#return-values]

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

### Examples [#examples]

#### Objective-C [#obj-c]

Here's an example to increment the count for the specified session attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1:

```objectivec
BOOL incremented = [NewRelic incrementAttribute@"rate"];
```

Here's another example to increment the count for the specified session attribute by the amount specified in `NSNumber*`:

```objectivec
BOOL incremented = [NewRelic incrementAttribute:@"rate" value:@1];
```

#### Swift [#swift]

Here's an example to increment the count for the specified session attribute by 1. If the attribute does not exist, it creates the attribute with a value of 1:

```swift
let incremented = NewRelic.incrementAttribute("rate")
```

Here's another example to increment the count for the specified session attribute by the amount specified in `NSNumber!`:

```swift
let incremented = NewRelic.incrementAttribute(name: String!, value: NSNumber!)
```

## Capacitor

### Syntax [#syntax]

```typescript
incrementAttribute(options: { name: string; value?: number; }) => void
```

### Description [#description]

Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.

### Parameters [#parameters]

| Parameter | Type     | Description                                         |
| --------- | -------- | --------------------------------------------------- |
| `name`    | `string` | Required. The name of the attribute to increment.   |
| `value`   | `number` | Optional. The amount to increment the attribute by. |

### Return values [#return-values]

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

### Example [#example]

```typescript
NewRelicCapacitorPlugin.incrementAttribute({ name: 'CapacitorAttribute', value: 15 })
```

## Cordova

### Syntax [#syntax]

```typescript
incrementAttribute(name: string, value?: number): void;
```

### Description [#description]

Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.

### Parameters [#parameters]

| Parameter | Type     | Description                                         |
| --------- | -------- | --------------------------------------------------- |
| `name`    | `string` | Required. The name of the attribute to increment.   |
| `value`   | `number` | Optional. The amount to increment the attribute by. |

### Return values [#return-values]

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

### Example [#example]

```js
NewRelic.incrementAttribute('CordovaCustomAttrNumber');
NewRelic.incrementAttribute('CordovaCustomAttrNumber', 5);
```

## .NET MAUI

### Syntax [#syntax]

```csharp
RecordCustomEvent(string eventType, string eventName, Dictionary<string, object> attributes): bool;
```

### Description [#description]

Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.

### Parameters [#parameters]

| Parameter | Type     | Description                                         |
| --------- | -------- | --------------------------------------------------- |
| `name`    | `string` | Required. The name of the attribute to increment.   |
| `value`   | `number` | Optional. The amount to increment the attribute by. |

### Return values [#return-values]

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

### Example [#example]

```csharp
// Increment by 1
CrossNewRelic.Current.IncrementAttribute("MAUINumAttr");
// Increment by value
CrossNewRelic.Current.IncrementAttribute("MAUINumAttr", 12.3);
```

## Flutter

### Syntax [#syntax]

```dart
incrementAttribute(name: string, value?: number): void;
```

### Description [#description]

Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.

### Parameters [#parameters]

| Parameter | Type     | Description                                         |
| --------- | -------- | --------------------------------------------------- |
| `name`    | `string` | Required. The name of the attribute to increment.   |
| `value`   | `number` | Optional. The amount to increment the attribute by. |

### Return values [#return-values]

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

### Example [#example]

```dart
NewrelicMobile.instance.incrementAttribute("FlutterCustomAttrNumber");
NewrelicMobile.instance.incrementAttribute("FlutterCustomAttrNumber", value :5.0);
```

## React Native

### Syntax [#syntax]

```js
incrementAttribute(name: string, value?: number): void;
```

### Description [#description]

Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.

### Parameters [#parameters]

| Parameter | Type     | Description                                         |
| --------- | -------- | --------------------------------------------------- |
| `name`    | `string` | Required. The name of the attribute to increment.   |
| `value`   | `number` | Optional. The amount to increment the attribute by. |

### Return values [#return-values]

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

### Example [#example]

```js
NewRelic.incrementAttribute('RNCustomAttrNumber');
NewRelic.incrementAttribute('RNCustomAttrNumber', 5);
```

## Unity

### Syntax [#syntax]

```csharp
incrementAttribute(string name, float value = 1) : bool;
```

### Description [#description]

Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.

### Parameters [#parameters]

| Parameter | Type     | Description                                         |
| --------- | -------- | --------------------------------------------------- |
| `name`    | `string` | Required. The name of the attribute to increment.   |
| `value`   | `number` | Optional. The amount to increment the attribute by. |

### Return values [#return-values]

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

### Example [#example]

```csharp
// Increment by 1
NewRelicAgent.IncrementAttribute('UnityCustomAttrNumber');
// Increment by value
NewRelicAgent.IncrementAttribute('UnityCustomAttrNumber', 5);
```

## Unreal Engine

### Syntax [#syntax]

```cpp
incrementAttribute(FString name,double value): void;
```

### Description [#description]

Increments the count of an attribute with a specified name. Overwrites its previous value and type each time it is called. If the attribute does not exists, it creates a new attribute. If no value is given, it increments the value by 1.

### Parameters [#parameters]

| Parameter | Type     | Description                                       |
| --------- | -------- | ------------------------------------------------- |
| `name`    | `string` | Required. The name of the attribute to increment. |
| `value`   | `number` | The amount to increment the attribute by.         |

### Example [#example]

```cpp
// Increment by 1
UNewRelicBPLibrary::incrementAttribute("Unreal Double",5.0);
```
