---
schema_version: "1"
id: 3faa15d990590aece8b4fe981edd9cb527ff6575173d4136fa3996260a833c6a
title: Set Contact Attribute Affinity
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/mktg/264-0-0/mc_ctc_set_contact_attribute_affinity.md
canonical_url: https://help.salesforce.com/s/articleView?id=mktg.mc_ctc_set_contact_attribute_affinity.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 245fe7793c3277e04abc4cde1d333c78d02dfbd365e654d1717104b00df775ca
description: Use Collect Tracking Code to build subscriber affinity models based on contact attributes.
products:
  - Marketing
  - Marketing Cloud Intelligence
release: "264"
---
# Set Contact Attribute Affinity

Use Collect Tracking Code to build subscriber affinity models based on contact attributes.

Match a contact attribute to a tagged catalog field to increase the subscriber's affinity for the value of that contact attribute. The amount of increase is less than what results from a purchase but more than the increase from a view.

```
<script type="text/javascript">       
    _etmc.push(["setOrgId", "MID"]);
    _etmc.push(["setUserInfo", {
        "email": "INSERT_EMAIL_OR_UNIQUE_ID",
        "details": {
            "gender: "female"
        }
    }]);
    _etmc.push(["trackPageView"]);	 
</script>
```

1. Copy the script and replace `gender` with the contact attribute you want to match.
2. Add the modified script in the header code on the detail pages of your website.

![Example](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-mktg-mc_data_management_and_analytics-264-0-0-production-enus/7988f60d-cd94-4b42-8836-dc11773564b5/images/icon_example.png)

Example

Lisa’s marketing director wants to increase the user affinity for catalog items where the gender field value is female for customers who identify as female. Lisa uses the Set Contact Attribute Affinity code to permanently boost any item that has the value female in the gender field.

#### See Also

- [Install Collect Tracking Code](https://help.salesforce.com/s/articleView?id=mktg.mc_ctc_install_collect_code.htm&release=264.0.0&type=5 "Learn how to configure your site to use Collect Tracking Code.")
- [Einstein Recommendations Catalog](https://help.salesforce.com/s/articleView?id=mktg.mc_pb_catalog.htm&release=264.0.0&type=5 "A catalog includes all fields that contain attributes used to make Einstein Recommendations. Einstein Recommendations filters assets based on these attributes. For instance, you can define assets in the recommendation pool based on a product’s color or size, or an article’s author and subject matter.")
- [Configure Custom Attributes for Einstein Recommendations](https://help.salesforce.com/s/articleView?id=mktg.mc_pb_configure_custom_attributes.htm&release=264.0.0&type=5 "You can create custom attributes to use with your recommendations. Unmapped fields are automatically used to make recommendations. For streaming updates, Custom Attributes Configuration is available after Marketing Cloud Engagement starts receiving data from your site.")

## User Affinity Tag Scenario

Configure a tag scenario to return the most popular items with a particular catalog attribute value. Set the recommendation engine to return items with attribute values that match the top affinities of a contact. This feature can power recommendations like Brands You Love or Items in your Favorite Colors.

1. Highlight the catalog attribute to use.
2. Select **Same as User Affinity** as the value.

![Example](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-mktg-mc_data_management_and_analytics-264-0-0-production-enus/7988f60d-cd94-4b42-8836-dc11773564b5/images/icon_example.png)

Example

Lisa’s marketing director wants to increase the user affinity for catalog items where the gender field value is female for customers who identify as female. Lisa uses the Set Contact Attribute Affinity code to permanently boost any item that has the value female in the gender field.

The SetUserInfo call can also include customer attributes specific to the contact on the site. The label can be any value and pulls into the Contact Profile exactly as passed. The value for each pair overwrites any value that is on the profile for the active user.

To use the affinity seeding functionality, the label must match the field in the catalog and the value passed must be assigned to a product on the catalog.

Customer Attributes cannot be exported and currently do not get passed into Marketing Cloud data extensions. The primary use cases for these values are to seed Contact Attribute Affinity and to use these values in rules in influence recommendations. For example, a financial institution adds AgeGroup as Minor for some users, and then creates a rule that prohibits the recommendation engine from recommending items where`OfferType=CreditCard when AgeGroup = Minor`.