# How can we help?

## Overview

You can update a contact attribute by using the Smarty attribute `crdl-setAttribute` within an anchor tag. It's a time-saving method to collect real-time data about a contact that you're entering into Cordial.

Link tracking must be enabled for this feature to work.

Contacts won't update when `crdl-setAttribute` is sent in a test message.

## Update a string attribute

The following code will update the string attribute `flavor` with the value of `vanilla`.

```
<a href="http://www.example.com" crdl-setAttribute-flavor="vanilla">Click to set flavor to "vanilla".</a>
```

## Update a number attribute

The following code will update the number attribute `points` with the value of `10`.

```
<a href="http://www.example.com" crdl-setAttribute-points="10">Click to set points to "10".</a>
```

### Increment a number attribute

Using the syntax `:inc` allows you to increment or decrement the value of a number attribute by providing a positive or negative value.

The following code will **increment** the number attribute `points` by `3`.

```
<a href="http://www.example.com" crdl-setAttribute-points:inc="3">Click to increment the points value by "3".</a>
```

The following code will **decrement** the number attribute `points` by `3`.

```
<a href="http://www.example.com" crdl-setAttribute-points:inc="-3">Click to decrement the points value by "3".</a>
```

## Update a date attribute

The following code will update the date attribute `expiration` to the current date.

```
<a href="http://www.example.com" crdl-setAttribute-expiration={$smarty.now|date_format}>click to set expiration date to today.</a>
```

The following code will update the date attribute `expiration` to 30 days in the future.

```
<a href="http://www.example.com" crdl-setAttribute-expiration={"+30 days"|date_format}>click to set expiration date to 30 days in the future.</a>
```

The following code will update the date attribute `expiration` to 30 days in the past.

```
<a href="http://www.example.com" crdl-setAttribute-expiration={"-30 days"|date_format}>click to set expiration date to 30 days in the past.</a>
```

## Update an array attribute

The following code will update the array attribute `categories` with the values `apparel`, `electronics`, and `home`.

```
<a href="http://www.example.com" crdl-setAttribute-categories="apparel,electronics,home">click to set the "categories" array with the values "apparel,electronics,home".</a>
```

This array update method only replaces the contact attribute value(s) with the ones specified; however it is unable to add/remove values. For more flexibility to replace, add, and remove attribute values, you can use [setArrayAttribute](https://support.cordial.com/hc/en-us/articles/360000323732-Update-an-attribute-when-clicking-a-link#setArrayAttribute).

## Modify array attribute values

To add or remove array attribute values, you can use the Smarty attribute `crdl-setArrayAttribute-<attribute-key>:<modifier>=”<comma separated list of items>"` within an anchor tag.

`setArrayAttribute` does not check for uniqueness, so it is possible to have duplicate array items.

### Default behavior without a modifier

When no modifier is provided, the default behavior for `crdl-setArrayAttribute` is to completely replace the existing array with the one that is given. The following code will **replace** the old value for the `color` array attribute to a new value of `yellow, orange`.

```
<a href="http://www.example.com" crdl-setArrayAttribute-color="yellow,orange">Change the value for the 'color' attribute to "yellow, orange".</a>
```

### Add array attribute item

Using the modifier `:add` lets you add comma-separated values to the specified attribute. The following code will **add** the `salad` and `fruit` values to the `food` attribute.

```
<a href="http://www.example.com" crdl-setArrayAttribute-food:add="salad, fruit">Add the values "salad" and "fruit" to the 'food' attribute array.</a>
```

### Remove array attribute item

The `:remove` modifier allows you to remove one or more comma-separated values from an attribute. The following code will **remove** the `jeans` value from the `clothes` attribute.

```
<a href="http://www.example.com" crdl-setArrayAttribute-clothes:remove="jeans">Remove the value "jeans" from the 'clothes' attribute array.</a>
```

In the next article, you can [learn how to disable link tracking](https://support.cordial.com/hc/en-us/articles/115009266788).
