> For the complete documentation index, see [llms.txt](https://docs.toomuchmedia.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.toomuchmedia.com/nats-admin/mass-mailing/further-reading/affiliate-linkcodes-in-emails.md).

# Affiliate Linkcodes in Emails

*Article Topics:* [*Linkcodes*](/getting-started/common-topics/linkcodes.md)*,* [*Emails*](/getting-started/common-topics/emails.md)*,* [*Affiliates*](/getting-started/common-topics/affiliates.md)

## Listing Linkcodes in Emails

When sending automated emails to affiliates in NATS, you can dynamically retrieve and display their unique linkcodes for a specified program and site using Smarty template functions.

{% code overflow="wrap" %}

```
{nats_list_linkcodes userid=$loginid data_only=1 program=program_number site=site_number}
```

{% endcode %}

Replace **program\_number** with the [program ID](/nats-admin/programs/program-overview.md#program-details) and site\_number with the [site ID.](/nats-admin/sites/site-management/site-overview.md#details-tab)

## Inserting the natscode in an Emailed Tour Link

You can construct dynamically tracked tour links for affiliates in your mass mailings by combining the `{nats_list_linkcodes}` Smarty function with your tour URL.

Each affiliate that receives an email containing the following text and Smarty code will get the link to the tour with their NATS code embedded in the URL:

{% code overflow="wrap" %}

```
URL?nats={nats_list_linkcodes userid=$toid program=program_number site=site_number 
  tour=tour_number data_only=1 code_only=1}{$linkcodes.program_number.site_number.tour_number.0.0.0}
```

{% endcode %}

Replace the following:

* **URL** with the URL to the tour
* **program\_number** with the [program ID](/nats-admin/programs/program-overview.md#program-details)
* **site\_number** with the [site ID](/nats-admin/sites/site-management/site-overview.md#details-tab)
* **tour\_number** with the [tour ID](/nats-admin/sites/site-management/tour-overview.md#details-tab)

#### Example

For a tour on example.com/tour, program number one, site number two, and tour number three, the code will look like this:

{% code overflow="wrap" %}

```
http://example.com/tour?nats={nats_list_linkcodes userid=$toid program=1 site=2 tour=3 data_only=1 code_only=1}{$linkcodes.1.2.3.0.0.0}
```

{% endcode %}

## Related Articles

{% content-ref url="/pages/uQooIYFSesigosWG0NLv" %}
[Linkcodes](/using-nats/nats-admin-features/linkcodes.md)
{% endcontent-ref %}

{% content-ref url="/pages/iIjQIW0c1F3dMN0Vwjfk" %}
[Mailing Overview](/nats-admin/mass-mailing/mailing-overview.md)
{% endcontent-ref %}
