# Email Marketing

> Discover how to integrate email marketing platforms with AnyTrack for conversion tracking. Track email campaign conversions, set up event mapping, and analyze attribution across your email marketing efforts.

The Email marketing channel remains one of the most profitable channels among marketers. Whether email marketing is part of your omnichannel marketing strategy or it's the core of your business, tracking beyond your open and click-through rate is key to your business growth.

## How AnyTrack Works

AnyTrack conversion tracking follows these steps regardless of your marketing channel:

1. A visitor lands on your website
2. AnyTrack automatically tracks engagements such as `FormSubmit` and `OutboundClick` events and passes an auto-generated `click_id` value into your forms
3. When the visitor purchases, AnyTrack tracks the conversion by stitching session data and conversion data with the `click_id`

## Email Marketing Tracking

### Option 1: Email Tracking for Lead Generation Campaigns

Track email campaign performance back to the initial ad campaign that acquired the lead when running lead generation campaigns on Facebook Ads.

**Before tracking email campaign performance, you must:**

1. Track the campaigns that acquired the Leads.
2. Track the form submission events.
3. Pass the AnyTack Click ID to your Optin forms and to your Email platforms.

#### Prerequisites

- Update your forms to capture the AnyTrack Click ID into a field named `atclid`. The hidden field automatically populates with the Click ID value
- Add the `atclid` field to your email platform
- Update your email campaign links to include the custom field and its value

**Example from Mailchimp:**

```http
https://myfunnel.foo?`utm_source`=mailchimp&`utm_medium`=email&`atclid`=*|ATCLID|*
```

### Why Add the `atclid` Parameter to Email Campaign Links?

#### Stitch Sessions Under the Same Click ID

When a visitor lands on your website with the `?atclid` parameter, AnyTrack recognizes it and stitches the session to the initial campaign that acquired the lead.

#### Cross-Device Tracking

Leads often click email links on different devices. Adding the `atclid` parameter enables cross-device tracking with minimal errors.

<Image align="center" className="border" border={true} src={readmeAsset1} />

Most email marketing platforms use similar tracking methods. This example uses Mailchimp to illustrate the email marketing tracking flow.

### Step 1: Mailchimp Form Tracking

1. In MailChimp go to **Audience > Signup forms > Settings**
2. Choose **Audience fields and |MERGE| tags**:\
   ![2.jpg](./2-jul-25-2022-05-18-00-97-pm-a5efc6ef06.jpg)
3. Click **Add a field > Text** and configure it:

<Image align="center" className="border" border={true} src={readmeAsset2} />

You can choose a different field name if preferred.

4. Create a form by going to **Embedded forms**. After customizing, copy the HTML code:

   **![copy.jpg](./copy-jul-25-2022-05-18-03-03-pm-46519d65e9.jpg)**

Add this HTML code to the input section:

```html
<input type="hidden" name="CLICK_ID" value="--CLICK-ID--">
```

Here is the complete HTML code:

```html
<!-- Begin Mailchimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/classic-10_7.css" rel="stylesheet" type="text/css">
<style type="text/css">
  #mc_embed_signup {
    background: #fff;
    clear: left;
    font: 14px Helvetica, Arial, sans-serif;
  }

  /* Add your own Mailchimp form style overrides in your site stylesheet or in this style block.       We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>
<div id="mc_embed_signup">
  <form action="https://gmail.us5.list-manage.com/subscribe/post?u=f55344cd125f5750fa6c74774&amp;id=fd12406f4f" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
    <div id="mc_embed_signup_scroll">
      <h2>Subscribe</h2>
      <div class="indicates-required">
        <span class="asterisk">*</span> indicates required
      </div>
      <div class="mc-field-group">
        <label for="mce-EMAIL">Email Address <span class="asterisk">*</span>
        </label>
        <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
  /* The new field which includes the AnyTrack --CLICK-ID-- placeholder */
        <input type="hidden" name="CLICK_ID" value="--CLICK-ID--">
      </div>
      <div id="mce-responses" class="clear">
        <div class="response" id="mce-error-response" style="display:none"></div>
        <div class="response" id="mce-success-response" style="display:none"></div>
      </div>
      <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
      <div style="position: absolute; left: -5000px;" aria-hidden="true">
        <input type="text" name="b_f55344cd125f5750fa6c74774_fd12406f4f" tabindex="-1" value="">
      </div>
      <div class="clear">
        <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button">
      </div>
    </div>
  </form>
</div>
<script type='text/javascript' src='//s3.amazonaws.com/downloads.mailchimp.com/js/mc-validate.js'></script>
<script type='text/javascript'>
  (function($) {
    window.fnames = new Array();
    window.ftypes = new Array();
    fnames[0] = 'EMAIL';
    ftypes[0] = 'email';
    fnames[1] = 'FNAME';
    ftypes[1] = 'text';
    fnames[2] = 'LNAME';
    ftypes[2] = 'text';
    fnames[3] = 'ADDRESS';
    ftypes[3] = 'address';
    fnames[4] = 'PHONE';
    ftypes[4] = 'phone';
    fnames[5] = 'BIRTHDAY';
    ftypes[5] = 'birthday';
    fnames[6] = 'CLICK_ID';
    ftypes[6] = 'text';
  }(jQuery));
  var $mcj = jQuery.noConflict(true);
</script>
<!--End mc_embed_signup-->
</link>
```

> 📘 **More**
>

### Step 2: Email Links Tracking

After doing that, we will add this code to our website to generate leads.

The last thing is to add to the links that we send in the email marketing the id placeholder of the ClickID.

In our case is `*|CLICK_ID|*` as we can see in Mailchimp:

*The ID placeholder might change from one platform to another.*

So, for example, the next link: `www.example.com` will change to: 

```
https://www.example.com?`atclid`=*|CLICK_ID|*
```

> ❗ ****
>
> The reason to use the parameter `atclid` is to stitch all sessions to a customer. If you don't pass the `atclid`, AnyTrack will create a new session and attribute it to the email campaign instead of the original touch point.

#### Verify Your Setup

When a user submits the form or clicks a link in your newsletter, it appears in AnyTrack with the user journey. 

**For example:**

### UTM Parameters for Email Campaigns (Recommended)

```
`utm_source`=mailchimp&`utm_medium`=email&`utm_campaign`={campaignToken}&`utm_content`={subject}&`atclid`=*|CLICK_ID|*
```

> 🚧 **Tokens**
>
> Tokens, Macros, Variables, Placeholders, Merge tags, Merge fields, personalization tags represent the dynamic variables that can be used to personalize your email campaigns.
>
> Consult your email platform documentation to find out how to use them on your campaigns.

## Affiliate Campaigns via Email Marketing

When promoting affiliate offers directly from email campaigns, update the campaign URL with the appropriate `subid` parameter.

For example, when promoting a `Maxweb` offer:

1. Find the `subid` parameter in your affiliate network's documentation or AnyTrack integration guide

<Image align="center" className="border" border={true} src={readmeAsset3} />

2. Update the email campaign destination URL with the `subid` parameter
3. Add the email platform token that will be substituted (e.g., `*|CLICK_ID|*` for Mailchimp)

```http
https://maxweburl.foo/8389/774/3/?`subid`=*|CLICK_ID|*
```

### Tracking Events

1. Email client clicks do not report directly to AnyTrack
2. When the visitor reaches the affiliate offer, the affiliate network records the `clickid`
3. Subsequent conversions attribute to the initial campaign that brought the subscriber

## Related Articles

- [Advanced Options](/docs/advanced-options-ms-ads)
- [Other Ad Networks](/docs/other-ad-networks)
- [Reddit UTM Parameters](/docs/reddit-ads)
