---
title: newrelic_add_custom_span_parameter (PHP agent API)
source: https://docs.newrelic.com/docs/apm/agents/php-agent/php-agent-api/newrelicaddcustomspanparameter-php-agent-api
---

## Syntax

```php
newrelic_add_custom_span_parameter(string $key, scalar $value)
```

Attaches a custom attribute (key/value pair) to the current span.

## Requirements

Agent version [9.12.0.268](https://docs.newrelic.com/docs/release-notes/agent-release-notes/php-release-notes/php-agent-9120268) or higher.

## Description

Add a [custom attribute](https://docs.newrelic.com/docs/agents/manage-apm-agents/agent-data/collect-custom-attributes) (a key and a value data pair) to the current span. (The call name is `newrelic_add_custom_span_parameter` because "custom attributes" were previously called "custom parameters.") For example, you can add a customer's full name from your customer database. This attribute appears in any span. You can also query the [Span](https://docs.newrelic.com/docs/insights/explore-data/attributes/apm-default-attributes-insights) for your custom attributes.

> #### ⚠️ IMPORTANT
>
> On spans, attributes added with `newrelic_add_custom_span_parameter` will take precedence over attributes added with `newrelic_add_custom_parameter`.

> #### ⚠️ IMPORTANT
>
> If you want to use your custom attributes, avoid using any of the [reserved terms used by NRQL](https://docs.newrelic.com/docs/insights/event-data-sources/custom-events/data-requirements-limits-custom-event-data/#reserved-words).

## Parameters

| Parameter         | Description                                                                                                                                                                                                                                                                                                        |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `$key` _string_   | Required. The name of the custom attribute. Only the first 255 characters are retained.                                                                                                                                                                                                                            |
| `$value` _scalar_ | Required. The value to associate with this custom attribute. If the value given is a **float** with a value of NaN, Infinity, denorm or negative zero, the behavior of this function is undefined. For other floating point values, the agent may discard 1 or more bits of precision (ULPs) from the given value. |

## Return values

Returns true if the parameter was added successfully.

## Examples

### Report a variable as the value [#basic-example]

```php
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
    // Record custom data about this web transaction
    newrelic_add_custom_span_parameter ('user_email', $user_email);
}
```
