sendProfileAttributes

Use sendProfileAttributes() to create or update user profile attributes in Data Activation. All attributes passed in one call are sent in one request.

Profile attributes store information about users that you can use to build audiences.

Syntax

PiwikTracker.sharedInstance()?.sendProfileAttributes(["name": "value"])
[[PiwikTracker sharedInstance] sendProfileAttributes:@{@"name": @"value"}];

Parameters

  • attributes NSDictionary, required – A dictionary of attribute name-value pairs. Values can be:
    • NSString, also for IP addresses.
    • NSNumber, including booleans.
    • NSDate, sent in the ISO 8601 format in UTC. Example: 2023-07-21T17:32:28Z.

Returns

  • true: The attributes were queued for sending.
  • false: The attributes weren't queued, for example, because the dictionary is empty, an attribute name is empty, or a value has an unsupported type.

Examples

To set the predefined revenue attribute and custom attributes for a favorite color, VIP status and contract end date:

PiwikTracker.sharedInstance()?.sendProfileAttributes([
    "analytics.revenue": 500,
    "favorite_color": "green",
    "vip": true,
    "contract_end": Date()
])
[[PiwikTracker sharedInstance] sendProfileAttributes:@{
    @"analytics.revenue": @500,
    @"favorite_color": @"green",
    @"vip": @YES,
    @"contract_end": [NSDate date]
}];

Notes

  • Predefined attributes use the analytics. prefix, for example, analytics.revenue.
  • Custom attributes must first be defined with an event data key in Data Activation. Use the event data key as the attribute name, not the attribute name returned by getProfileAttributes(). See how to import data to custom attributes.
  • The profile is identified by the visitor ID and, if set, the user ID. The user ID isn't sent when isAnonymizationEnabled is true.
  • Attributes are queued and sent with analytics events, so they aren't lost when there's no network connection. Requests rejected by Data Activation with HTTP 400, 402, 404, or 422 aren't retried, for example, when an attribute is unknown or the module is disabled. Server and network errors are retried later.
  • Data Activation processes attributes asynchronously, so new values may not be available immediately.

Related methods


Did this page help you?