---
title: Tracking marketing emails on MVC sites
related:
  - https://docs.kentico.com/k12sp/on-line-marketing-features/managing-your-on-line-marketing-features/email-marketing/tracking-marketing-emails.md
  - https://docs.kentico.com/k12sp/on-line-marketing-features/configuring-and-customizing-your-on-line-marketing-features/configuring-email-marketing/handling-newsletter-subscriptions-on-mvc-sites.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).

You can use the [email marketing](https://docs.kentico.com/k12sp/on-line-marketing-features/managing-your-on-line-marketing-features/email-marketing.md) features of Kentico with websites that are presented by a [separate MVC application](https://docs.kentico.com/k12sp/developing-websites/mvc-development-overview.md). In this scenario, you manage and send marketing emails from the administration interface of the Kentico application. All settings related to email marketing that you configure in Kentico apply (both global settings and the configuration of individual email feeds).

When you have [tracking](https://docs.kentico.com/k12sp/on-line-marketing-features/managing-your-on-line-marketing-features/email-marketing/tracking-marketing-emails.md) enabled for an email feed (opened emails and clicked links), the system collects data by processing hidden image requests and link redirects. On Portal Engine websites, the Kentico application handles these tracking requests. For MVC scenarios, you need to register the email tracking functionality into the MVC application. This allows the email tracking to work even when the related Kentico application is not publicly available.

> **Note:** **Important**
>
> When you send out a marketing email, Kentico generates tracking links according to the type of the site containing the given email feed.
>
> - For content-only sites (i.e. MVC sites), the base URL of the tracking links uses the site's _Presentation URL_.
> - For standard sites, the tracking links target the handlers within the Kentico application itself.
>
> This means your site in Kentico _**must be marked as content-only**_ if you wish to handle marketing email tracking on the side of the MVC website.

Perform the following steps to register email tracking functionality for your MVC application:

1. Open your MVC project in Visual Studio.
2. Enable the email tracking feature by calling the **UseEmailTracking** method of the _ApplicationBuilder_ instance.

   - Create an **EmailTrackingOptions** object and pass it as the parameter of the _UseEmailTracking_ method.
   - Enable the feature at the start of your application's life cycle, for example in the **Application\_Start** method of your project's **Global.asax** file.

     > **Info:** MVC projects created by the [installer](https://docs.kentico.com/k12sp/installation/installing-kentico-mvc-projects.md) contain the _ApplicationConfig_ class, whose _RegisterFeatures_ method is called in the _Application\_Start_ method by default. You can use this class to encapsulate all of your _ApplicationBuilder_ code (enabling and configuring of Kentico MVC features).

     > **Note:** **Note**: The feature must be enabled **before** you register routes into the application's _RouteTable_. The _Kentico().MapRoutes()_ method adds required routes based on the set of enabled features.

     ```csharp

     using Kentico.Web.Mvc;
     using Kentico.Newsletters.Web.Mvc;

     ...

     protected void Application_Start()
     {
         ...

         // Gets the ApplicationBuilder instance
         // Allows you to enable and configure selected Kentico MVC integration features
         ApplicationBuilder builder = ApplicationBuilder.Current;

         // Enables the email tracking feature, registers the following routes by default:
         // "CMSModules/Newsletters/CMSPages/Track.ashx" route for opened marketing email tracking
         // "CMSModules/Newsletters/CMSPages/Redirect.ashx" route for clicked link tracking
         builder.UseEmailTracking(new EmailTrackingOptions());

         ...
     }

     ```

Enabling the _UseEmailTracking_ feature ensures that the system registers routes that handle opened email and clicked link tracking requests

When a recipient opens an email or clicks a link in the content, the system automatically sends the tracking requests through the MVC site. The registered routes ensure that the tracking data is processed and logged into the shared Kentico database. From the point of view of the recipient reading the email, everything works the same way as when handling tracking through the Kentico application.
