Custom Attributes

Set typed custom attributes on a Pulsate user and increment or decrement numeric values.

In addition to the system attributes that Pulsate collects on your customers, you can pass an unlimited number of custom attributes. This is useful for collecting additional data on specific users — for example whether they have made a purchase in the app yet, or what plan they are on (free / paid).

Any custom attribute you pass to Pulsate automatically appears as a new filter option in the segment builder. You can combine system filters (such as "last active" or "number of sessions") with your custom filters. For example, you could build a segment for users that were last active less than 1 week ago and where number of purchases is more than 2 — combining Pulsate's system filters with dynamic filters created from your custom attributes to build highly targeted campaigns.

When you send a custom attribute, you must tell Pulsate its data type so the correct segmentation options can be presented. For instance, a date shows date-related options, whereas a boolean shows only true/false.

Creating attributes

Call the createAttribute(_:with…:) method that matches your value's type on the PULPulsateManager instance.

import PULPulsate

guard let manager = PULPulsateFactory.getDefaultInstance() else { return }

String:

manager.createAttribute("Property", withString: "value")

Decimal:

manager.createAttribute("Property", withDecimal: NSDecimalNumber(value: 2.0))

Integer:

manager.createAttribute("Property", withInteger: 2)

Boolean:

manager.createAttribute("Property", withBoolean: true)

Date — the value is sent to the server in the format yyyy-MM-dd HH:mm:ss, in UTC.

manager.createAttribute("Property", withDate: Date())

📘

Note

Empty or nil attribute names and values are silently ignored.

Incrementing / decrementing custom attributes

You can also increment or decrement numeric attributes. This is useful when you want to increase or decrease a value without knowing its current value. Both integer and decimal attributes are supported.

Incrementing (integer):

manager.incrementIntegerAttribute("number_of_transactions", withInteger: 1)

This increments the attribute named number_of_transactions by 1. If the attribute does not yet exist, it is created and initialized to 0, then incremented. A negative increment value acts as a decrement — passing -1 decrements by 1.

Decrementing (integer):

manager.decrementIntegerAttribute("number_of_transactions", withInteger: 1)

This decrements the attribute named number_of_transactions by 1. If the attribute does not yet exist, it is created and initialized to 0, then decremented. A negative decrement value acts as an increment — passing -1 increments by 1.

Decimal attributes work the same way, using NSDecimalNumber:

manager.incrementDecimalAttribute("account_balance", withDecimal: NSDecimalNumber(value: 10.50))
manager.decrementDecimalAttribute("account_balance", withDecimal: NSDecimalNumber(value: 10.50))

Next steps