Syntax
newrelic_set_user_attributes(string $user_value, string $account_value, string $product_value)
Create user-related custom attributes. newrelic_add_custom_parameter is more flexible.
Requirements
Agent version 3.1.5.111 or higher.
Description
Tip
This call only allows you to assign values to pre-existing keys. For a more flexible method to create key/value pairs, use newrelic_add_custom_parameter
.
As of release 4.4, calling:
newrelic_set_user_attributes("a", "b", "c");// is equivalent to calling these three methods:
newrelic_add_custom_parameter("user", "a"); newrelic_add_custom_parameter("account", "b"); newrelic_add_custom_parameter("product", "c");
All three parameters are required, but they may be empty strings.
Parameters
Parameter | Description |
---|---|
string | Required (can be empty string). Specify a name or username to associate with this page view. This value is assigned to the |
string | Required (can be empty string). Specify the name of a user account to associate with this page view. This value is assigned to the |
string | Required (can be empty string). Specify the name of a product to associate with this page view. This value is assigned to the |
Return values
This function will return true
if the attributes were added successfully.
Examples
Record three user attributes
function example() { if (extension_loaded('newrelic')) { // Ensure PHP agent is available newrelic_set_user_attributes("MyUserName", "MyAccountName", "MyProductName"); }}
Record two user attributes and one empty attribute
function example() { if (extension_loaded('newrelic')) { // Ensure PHP agent is available newrelic_set_user_attributes("MyUserName", "", "MyProductName"); }}