You are able to update a contact attribute by using the Smarty attribute crdl-setAttribute
within an anchor tag.
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>
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 learn how to disable link tracking.
Comments
0 comments
Please sign in to leave a comment.