---
title: Log email activities
related:
  - https://docs.kentico.com/documentation/developers-and-admins/digital-marketing-setup/set-up-email-tracking.md
  - https://docs.kentico.com/documentation/business-users/digital-marketing/emails/track-email-statistics.md
  - https://docs.kentico.com/documentation/developers-and-admins/digital-marketing-setup/set-up-activities.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

> **License:** **Email license requirements**
>
> The license tier required for email features depends on the size of the [email channels](https://docs.kentico.com/documentation/developers-and-admins/digital-marketing-setup/email-channel-management.md) that you use:
>
> - Email microchannels – available for all license tiers
> - Standard size email channels – require the **Advanced** license tier
>
> To learn more, see the description of the [Channel size](https://docs.kentico.com/documentation/developers-and-admins/digital-marketing-setup/email-channel-management.md#create-and-configure-email-channels) property for email channels.

Unlike general email statistics, [email activities](https://docs.kentico.com/documentation/business-users/digital-marketing/emails/track-email-statistics.md#contact-activities-for-emails) are not anonymous, and provide information about the actions of individual email recipients. To ensure compliance with data protection regulations, email activities are **not logged by default**.

Developers need to [implement](#implement-an-email-tracking-activity-evaluator) logic that decides when it is possible to track email activities for specific contacts.

> **Note:** **Email tracking prerequisite**
>
> To log email activities, you must also have [Email tracking](https://docs.kentico.com/documentation/developers-and-admins/digital-marketing-setup/set-up-email-tracking.md) properly configured for your application.

## Implement an email tracking activity evaluator

To log email activities, you must create and register an `IEmailActivityTrackingEvaluator` service that decides when the logging is allowed for specific contacts and emails. The implementation depends on your project's requirements, on the target audience of your emails, and the [data protection](https://docs.kentico.com/documentation/developers-and-admins/data-protection.md) regulations you need to comply with.

A common approach is to prepare one or more tracking [consents](https://docs.kentico.com/documentation/developers-and-admins/data-protection/consent-management.md), and only log activities for contacts who agree to be tracked.

The following example demonstrates how to enable email activity logging based on a consent:

1. Open your Xperience solution in Visual Studio.
2. Create a new class implementing the `IEmailActivityTrackingEvaluator` interface.
   - See [Integrate custom code](https://docs.kentico.com/documentation/developers-and-admins/customization/integrate-custom-code.md) for best practices about adding custom code to your project.
3. Add the `IsTrackingAllowed` method.
   - Return a true or false value based on the provided `ContactInfo` and `EmailConfigurationInfo` arguments.
4. Register the implementation using the `RegisterImplementation` assembly attribute.

```csharp title="IEmailActivityTrackingEvaluator example"
using System.Threading.Tasks;

using CMS;
using CMS.ContactManagement;
using CMS.DataEngine;
using CMS.DataProtection;
using CMS.EmailLibrary;

using Kentico.OnlineMarketing.Web.Mvc;

// Registers the custom implementation of IEmailActivityTrackingEvaluator
[assembly: RegisterImplementation(typeof(IEmailActivityTrackingEvaluator), typeof(CustomEmailActivityTrackingEvaluator))]

public class CustomEmailActivityTrackingEvaluator(IConsentAgreementService consentAgreementService, IInfoProvider<ConsentInfo> consentInfoProvider) : IEmailActivityTrackingEvaluator
{
    public async Task<bool> IsTrackingAllowed(ContactInfo contact, EmailConfigurationInfo emailConfiguration)
    {
        // Gets the 'TrackingConsent' consent
        ConsentInfo consent = await consentInfoProvider.GetAsync("TrackingConsent");

        // Returns a true value if the contact has given an agreement for the consent
        return consent is not null && consentAgreementService.IsAgreed(contact, consent);
    }
}
```

Email activities are now only logged if the contact representing the recipient has given an agreement for the specified consent.
