# How to handle link tracking in emails?

Batch provides a flexible way to manage links in emails, combining click tracking and link enrichment to help you understand how recipients interact with your messages.

## Link enrichment with URL parameters (UTM)

Batch allows you to define URL parameters at the email level. These parameters can be used either as standard UTM parameters or as fully custom query parameters (with any key and value), and are automatically appended to every link in the email.

<div align="center" data-full-width="true"><figure><img src="https://509463063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfiAYaWDWqtFZeXxyg67F%2Fuploads%2FtukNZBnsDnyCQT60IGi5%2Fimage.png?alt=media&#x26;token=e94fda34-26de-4c60-830b-3e3d2e05c6f5" alt="" width="375"><figcaption><p>utm parameters</p></figcaption></figure> <figure><img src="https://509463063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfiAYaWDWqtFZeXxyg67F%2Fuploads%2FmY6Qvr6zzX8hLwDZKyuQ%2Fimage.png?alt=media&#x26;token=17b094d2-6f59-4087-9609-04872e2767d7" alt="" width="375"><figcaption><p>custom parameters</p></figcaption></figure></div>

URL parameters are configured once from the email composer, in the **Message settings** tab, and then applied to all links included in the email content (text links, buttons, etc.), except for the Batch unsubscribe link (`{{emailComposerUnsubscribeLink()}}`).

All URL parameters defined at the email level are applied consistently to every link in the message. If you need to add a parameter that is specific to a single link, it can be added directly in that link's.

UTM parameters work with personalization attributes as long as the attribute content contains only valid characters, without spaces, special symbols, or accents.

**Valid characters for URL parameter values using Personalization:**

* **Letters:** a–z, A–Z
* **Numbers:** 0–9
* **Safe characters:** `-` (dash), `_` (underscore), `.` (dot), `~` (tilde)

Characters such as spaces, special symbols (`?`, `=`, `&`, `#`), or non-ASCII characters should be properly URL-encoded before being used in personalization attributes.

## Click tracking modes

These allow you to **track generic indicators** (e.g. click-through rate), but also to see the number of **clicks on each of the links** in your e-mails, so you can understand which part of your message converts best and optimize your content (e.g. clicks concentrated on the unsubscribe link or the buy button).

On the **Dashboard**, you can see both the generic clicks indicator and the list of links for each of your email campaign/automation analytics👇

<figure><img src="https://509463063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfiAYaWDWqtFZeXxyg67F%2Fuploads%2Ffec99ev9TN1UXbksEhXV%2FCleanShot%202024-10-08%20at%2012.01.34%402x.png?alt=media&#x26;token=d27a9dd2-3458-41d1-a4ac-71eff4e19c0b" alt=""><figcaption></figcaption></figure>

Batch offers different ways to track clicks, depending on your use case. These options define how clicks are counted and displayed in analytics.

* Track clicks **separately**, per URL.
* **Group clicks** on similar links under a "link name".
* **Disable the click** **tracking** for one or several URLs.

{% hint style="success" %}
These 3 options are here to cater to different scenarios and needs, giving you the flexibility you require to accurately understand and interpret your data.
{% endhint %}

### Default click tracking <a href="#h_054a32da56" id="h_054a32da56"></a>

By default, Batch will track clicks on all of the URLs of your email. The raw clicked URL will be displayed in the campaigns analytics 👇

<figure><img src="https://509463063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfiAYaWDWqtFZeXxyg67F%2Fuploads%2Fy1wh6WYYTRxkjXjatmzY%2FScreenshot%202024-04-09%20at%2015.35.49.png?alt=media&#x26;token=4b9f95c9-d3bd-4ce9-99c3-cd5ceffad350" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
While easy to use, this method is not suited for **personalized links** that contain personal/sensitive data, or e-mails that contain links unique for each user (e.g. a single-use promocode, a password reset token, etc). These URLs would be exposed in the campaign analytics.
{% endhint %}

### Grouped link tracking <a href="#h_e1863a7151" id="h_e1863a7151"></a>

Allows you to group the click tracking behind a "**link name**" defined on your end while editing the email template (e.g. "**social\_networks**" for your social network links in the footer of your email) 👇

<figure><img src="https://509463063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfiAYaWDWqtFZeXxyg67F%2Fuploads%2FXIqLAnCBiaYPisd7Piii%2Fgroupedlinktracking.png?alt=media&#x26;token=5abfcca4-3446-498c-bc37-0181204f7836" alt=""><figcaption></figcaption></figure>

It is suitable for **personalized links** to avoid having too many raw personalized links in the stats or links that don't have enough value to be tracked individually.

Here are several cases where using a link name tracking is useful:

* **Privacy & Double opt-in automations**: Attaching a link name to URLs in your email (e.g. `validation_url`) is the best solution if you don't want to expose raw personalized URL in the campaigns analytics, but still want to track clicks on these links.
* **Deduplication of URLs with personalization**: A single link with a personalization variable that changes for each user (e.g. [https://website.com/?promocode={{unique\_code}}](https://website.com/?promocode=)) will result in hundreds/thousands of different links tracked for the same URL in the template. Using a link name “`redeem_link`” to track all of the clicks on that link in the template is a better option.
* **Grouping of similar links**: You can group similar links to gain visibility on the type of links clicked by users.
* **Tracking the same link separately:**
  * **Why**? If you have the same URL  several times in your email, Batch will attribute all of the clicks to a single URL in the campaign analytics. While this is great to have a synthetic view on which URLs were clicked, this can be an issue if you want to know from where the clicks are coming from (e.g. from the URL in the header, or from the same URL in the body of the email).
  * **How**? Use a different link name for the same URL, according to where the URL is placed (e.g. `mylink_body`) and use a different one for the same link, placed in the footer (e.g. `mylink_footer`). In the campaign analytics, you will be able to measure the distribution of clicks on that specific link, based on where it is placed in the email.

To attach a link name to a URL in your email, simply add a `data-msys-linkname="NAME"` parameter to the `<a>` html tag of the link:

```
<a data-msys-linkname="NAME" href="[URL]">My link</a>
```

Replace `NAME` with the link name you want to use. Link names have a maximum length of **63 characters** and are truncated if they exceed the limit.

### Disabled click tracking <a href="#h_77aa96a28f" id="h_77aa96a28f"></a>

Allows you to disable link tracking completely if you want to avoid showing links with personal/sensitive data (e.g. a password reset token, etc) in Batch analytics, or if your links are unique for each users and you don't want to have thousands different entries in the analytics or for any technical reasons (e.g. universal link support).

Lastly, you may need to disable click tracking on a specific link, and this option is suitable for cases where **no click is to be tracked**.

It applies to these two cases mainly:

* **Privacy** & confidential links
* **Universal links**

To implement this, you only need to add a `data-msys-clicktrack="0"` parameter to the `<a>` html tag of the link:

```
<a data-msys-clicktrack="0" href="[URL]">My link</a>
```

{% hint style="warning" %}
Link tracking cannot be disabled for a whole template, the option is only available at each level.
{% endhint %}
