track().profileAttribute()

The track().profileAttribute() method creates or updates attributes of the user profile in Data Activation. All attributes added with add() are sent in one request.

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

Syntax

TrackHelper.track()
  .profileAttribute("name", "value")
  .add("name", "value")
  .with(tracker)
TrackHelper.track()
  .profileAttribute("name", "value")
  .add("name", "value")
  .with(getTracker());

Parameters

name (string, required)

The name of the profile attribute. For custom attributes, use the event data key defined in Data Activation, not the attribute name returned by getProfileAttributes().

value (string, number, boolean or Date, required)

The value of the profile attribute. Dates are sent in the ISO 8601 format in UTC. Example: 2023-07-21T17:32:28Z. IP addresses are sent as strings.

add() (chain method)

Adds more attributes that you want to send in the same request.

Examples

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

TrackHelper.track()
  .profileAttribute("analytics.revenue", 500)
  .add("favorite_color", "green")
  .add("vip", true)
  .add("contract_end", Date())
  .with(tracker)
TrackHelper.track()
  .profileAttribute("analytics.revenue", 500)
  .add("favorite_color", "green")
  .add("vip", true)
  .add("contract_end", new Date())
  .with(getTracker());

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. See how to import data to custom attributes.
  • The profile is identified by the visitor ID and the user ID, if it is set. The user ID isn't sent if setAnonymizationState(true) is set.
  • Attributes are queued and sent with analytics events, so they aren't lost if 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?