Custom Message Metadata: Linking to your CRM or backend database

Custom metadata is one of my favorite features in Mandrill because it's a powerful way to customize Mandrill for the unique needs of your organization, app, or website and it's simple to set up. With custom templates for metadata fields, the Activity view in your Mandrill account can display data about your emails and link directly to your CRM or backend database.

Many web-based CRMs have a unique URL for each contact, company, or organizational structure. We're going to use the URL structure to help link Mandrill to the CRM.

Determine how your CRM or database URL structure works

Before you do anything in Mandrill, you'll want to figure out how your particular CRM or backend database constructs URLs for users or contacts. For example, in Highrise, contacts can be accessed at a URL like this:


(where <yourdomain> is your custom Highrise subdomain and <unique-identifier> is the unique ID that is assigned for each record, whether an individual or a company).

Other CRMs and databases may use different URL formats, so check the documentation or see if you can find a common pattern.

Create the metadata field(s) that Mandrill will index

Go to Settings > Custom Metadata to begin configuring the custom metadata field(s) that will be indexed by Mandrill. You can create as many metadata fields for your emails as you'd like. Select up to 10 metadata fields to be indexed so they can be used for searching and so that they're displayed as columns in your outbound activity. Even if you have more than 10 fields or if your fields aren't being indexed, metadata is included in webhook events and when searching your outbound activity through the API.

Add a field named 'Highrise_id' (or something that will be useful for your purposes) for Mandrill to index. Next, define your custom template. In this case, when I view the Outbound Activity, in addition to the value for the metadata field (which will always be shown and can be clicked to search based on that value), I want text that says 'contact record in Highrise' with the word 'Highrise' linked to the URL for that contact:

contact record in <a href="{{value}}">Highrise</a>

Create a new custom metadata field for Mandrill to index

Nothing too fancy there. For a recipient with a Highrise id of "12345", that value ("12345") will be displayed in the activity view, along with text below it that will link here:

https://<yourdomain> A new column added to the Outbound Activity view in Mandrill for the metadata

But I could get fancier and track the recipient's company name and company id, too, and reference different metadata fields for my template:

Adding multiple metadata fields that can reference each other

In the above setup, I'll have three fields tracked, Highrise_id (for the individual recipient's Highrise record), Company_ID (for the unique id of the company), and company_name. The Highrise_id will link to the Highrise record for the recipient. The Company_ID doesn't have a template defined, so it will just use the default behavior, and the company_name field will link to the Highrise record for that particular company by referencing the Company_ID so I can get more details about them easily.

Append metadata to your outbound emails in Mandrill

The last step is to start including the custom metadata when I actually send the emails through Mandrill. You can define metadata through the API, or with Mandrill's custom SMTP headers. With multiple recipients, the global options allow you to specify details for every recipient (or default values for those users who don't have data), and the recipient options allow you to specify per-recipient metadata.

Other CRMs

Now that you have an idea of how you can link from Mandrill to Highrise contact records, the same type of information can be used to link to other CRMs or to your own custom database.

So, there you have it: a quick and easy way to begin integrating Mandrill with your existing database or CRM. Are you doing anything interesting with custom metadata? Curious about other ways to use custom metadata? Let us know in the comments!