> ## Documentation Index
> Fetch the complete documentation index at: https://ahasend.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> AhaSend stores all message data in the EU. See /facts.
> The API base URL is https://api.ahasend.com. Send the API key in the Authorization: Bearer header. See /api-reference/authentication.
> Use send.ahasend.com for SMTP. Ports 25, 587 and 2525 use STARTTLS. Port 465 is not supported. See /smtp.
> For send-only integrations, create an API Key v2 under Credentials → Add and scope it to messages:send:{your-domain}. See /send-api/credentials and /api-reference/scopes.

# Email Click Tracking: Setup and Link Rules

> Track link clicks in AhaSend emails: enable click tracking account-wide or per message, exclude links with data-as-no-track, and fix links that aren't tracked.

AhaSend click tracking records visits to links in your emails; this guide shows how to enable it and read click events.

Available on Free, Pro and Max. See [plans and features](https://ahasend.com/docs/facts.md#plans-and-features).

Click tracking is off by default. Enable it in account settings or override it per message. Tracked URLs use the AhaSend tracking domain unless you configure a [custom tracking CNAME](https://ahasend.com/docs/domains.md).

## How Click Tracking Works

Click tracking works by automatically rewriting all eligible links in your HTML emails to redirect through AhaSend's tracking servers. When a recipient clicks a tracked link, they're briefly redirected through AhaSend's servers before being sent to the original destination, allowing the click to be recorded.

> [accordion] The Tracking Process
>
> 1. **Link Detection:** AhaSend scans HTML emails for eligible links
> 2. **URL Rewriting:** Original URLs are replaced with AhaSend tracking URLs
> 3. **Email Delivery:** Email is delivered with rewritten tracking links
> 4. **Link Clicked:** Recipient clicks on a link in the email
> 5. **Redirect & Track:** AhaSend records the click and redirects to original URL
> 6. **Analytics Updated:** Click data appears in your dashboard and webhooks

> [accordion] Link Requirements
>
> **Eligible links must be:**
>
> * Wrapped in HTML `<a>` tags with `href` attribute
> * Use `http://` or `https://` protocol
> * Properly formatted with quoted URLs
> * No spaces around the `=` in href attribute
>
> **Examples of valid links:**
>
> * `<a href="https://example.com">Click here</a>`
> * `<a href="http://www.example.com/page">Visit page</a>`
> * `<a target="_blank" href="https://example.com">Open in new tab</a>`

### Common Accuracy Issues

> [accordion] Links Not Tracked
>
> **Common causes of untracked clicks:**
>
> * Links missing `http://` or `https://` protocol
> * Malformed HTML anchor tags
> * Plain text emails (tracking requires HTML)
> * Links with `data-as-no-track` attribute
>
> **Impact:** Actual click rates may be higher than reported

> [accordion] Invalid Link Formats
>
> **These formats will NOT be tracked:**
>
> * `<a href="example.com">Link</a>` (missing protocol)
> * `<a href="www.example.com">Link</a>` (missing protocol)
> * `<a href= "https://example.com">Link</a>` (space before quote)
> * `<a href = "https://example.com">Link</a>` (spaces around =)

> [accordion] Email Client Variations
>
> **Click behavior varies by client:**
>
> * Some clients pre-fetch links, inflating click counts
> * Mobile clients may handle redirects differently
> * Corporate firewalls may block tracking redirects
> * Email security scanners may trigger false clicks

## Privacy Considerations

Click tracking has significant privacy implications that you should consider:

> [!WARNING]
>
> **Privacy Compliance:** Ensure your use of click tracking complies with applicable privacy laws (GDPR, CCPA, etc.) in your jurisdiction. Consider disclosing tracking in your privacy policy.

### Privacy Impact

> [accordion] Information Collected
>
> When someone clicks a tracked link, AhaSend may collect:
>
> * **Timestamp:** When the link was clicked
> * **IP Address:** Recipient's approximate location
> * **User Agent:** Browser and device information
> * **Original URL:** The destination they were trying to reach
> * **Click Count:** How many times the link was clicked

> [accordion] Recipient Awareness
>
> **Recipients may notice:**
>
> * Brief redirect through AhaSend's tracking domain
> * Different URL in browser address bar during redirect
> * Slight delay before reaching final destination
>
> **Recipients typically cannot see:**
>
> * That their clicks are being tracked
> * What information is being collected
> * Analytics and reporting data

> [accordion] Opt-out Considerations
>
> **Recipients can avoid tracking by:**
>
> * Using privacy-focused browsers or extensions
> * Reading emails in plain text mode
> * Manually copying/pasting URLs instead of clicking

## Enabling Click Tracking

Click tracking can be controlled at different levels depending on how you send emails:

### Account-Wide Settings

Configure your default click tracking preference in your AhaSend dashboard:

1. Navigate to **[Account Settings](https://dash.ahasend.com/account/-/settings)** in your dashboard
2. Toggle **Click Tracking** on or off
3. This setting applies to all emails unless overridden per message

### Per-Message Override

Override account settings for individual emails using different methods:

## SMTP with Special Headers

For SMTP email sending, use the `ahasend-track-clicks` header to control tracking:

```plaintext SMTP Example theme={null}
From: hello@yourdomain.com
To: user@example.com
Subject: Product Update with Click Tracking
ahasend-track-clicks: true
Content-Type: text/html

<html>
<body>
<h1>New Product Features</h1>
<p>Check out our <a href="https://example.com/features">latest features</a>!</p>
<p>Excluded link: <a href="https://example.com/unsubscribe" data-as-no-track>Unsubscribe</a></p>
</body>
</html>
```

> [!NOTE]
>
> **Header Details:** The `ahasend-track-clicks` header accepts `true` or `false` values and overrides your account-wide click tracking setting for individual emails.

For complete SMTP header documentation, see [Special Email Headers](https://ahasend.com/docs/smtp/special-headers.md).

## API v2 Implementation

API v2 (`/v2/accounts/{account_id}/messages`) provides native support for tracking configuration:

```json API v2 Example theme={null}
{
  "from": {
    "email": "hello@yourdomain.com",
    "name": "Your Company"
  },
  "recipients": [
    {
      "email": "user@example.com",
      "name": "John Doe"
    }
  ],
  "subject": "Newsletter with Click Tracking",
  "html_content": "<h1>Newsletter</h1><p>Visit our <a href=\"https://example.com\">website</a> for more info!</p>",
  "tracking": {
    "click": true
  }
}
```

> [!NOTE]
>
> **API v2 Advantage:** API v2 provides dedicated `tracking` field at the root level, making it easier to manage tracking settings without dealing with custom headers.

For complete API v2 documentation, see [Send Emails using the API](https://ahasend.com/docs/api-reference/messages/create-message.md).

## API v1 Implementation

For API v1 (`/v1/email/send`), include tracking headers in the `content.headers` field:

```json API v1 Example theme={null}
{
  "from": {
    "name": "Your Company",
    "email": "hello@yourdomain.com"
  },
  "recipients": [
    {
      "name": "John Doe",
      "email": "user@example.com"
    }
  ],
  "content": {
    "subject": "Newsletter with Click Tracking",
    "html_body": "<h1>Newsletter</h1><p>Check out our <a href=\"https://example.com/offers\">special offers</a>!</p>",
    "headers": {
      "ahasend-track-clicks": "true"
    }
  }
}
```

## Excluding Individual Links

To exclude specific links from click tracking while keeping it enabled for the email, add the `data-as-no-track` attribute:

```html HTML Example theme={null}
<p>
  Tracked link: <a href="https://example.com/product">View Product</a>
</p>
<p>
  Untracked link: <a href="https://example.com/unsubscribe" data-as-no-track>Unsubscribe</a>
</p>
```

> [!TIP]
>
> **Use Case:** Commonly used for unsubscribe links, privacy policy links, or other administrative links where tracking isn't needed or desired. AhaSend never tracks its own [unsubscribe link](https://ahasend.com/docs/campaigns/unsubscribe.md) (`{{unsubscribe_url}}`).

## Best Practices

> [accordion] Link Formatting
>
> **Ensure proper link structure:**
>
> * Always include `http://` or `https://` protocol
> * Use proper HTML anchor tag formatting
> * Avoid spaces in href attribute formatting
> * Test links across different email clients
> * Use absolute URLs rather than relative paths

> [accordion] Privacy and Compliance
>
> **Respect recipient privacy:**
>
> * Disclose click tracking in your privacy policy
> * Consider providing opt-out mechanisms
> * Comply with GDPR, CCPA, and other privacy regulations
> * Be transparent about data collection purposes

> [accordion] Link Strategy
>
> **Optimize link placement and content:**
>
> * Use clear, descriptive link text
> * Place important links prominently in email content
> * Avoid too many tracked links in a single email
> * Use `data-as-no-track` for administrative links
> * Test link functionality before sending campaigns

> [accordion] Data Analysis
>
> **Analyze click data effectively:**
>
> * Focus on engagement trends over time
> * Compare click performance between campaigns
> * Segment data by recipient characteristics
> * Use A/B testing to optimize link placement and content

## Related Guides

* [Account quickstart](https://ahasend.com/docs/quickstart.md), [Domain setup](https://ahasend.com/docs/domains.md), [Click event payload](https://ahasend.com/docs/api-reference/webhooks/message-clicked.md).
* [Open tracking](https://ahasend.com/docs/tracking/open-tracking.md), [API tracking options](https://ahasend.com/docs/api-reference/messages/create-message.md), [SMTP tracking headers](https://ahasend.com/docs/smtp/special-headers.md).
* [Plans and limits](https://ahasend.com/docs/facts.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.