Development tools

How to incorporate Mixpanel analytics into your email communication by integrating it with Mailgun

Jaha Jereshov
Back-end Developer
February 15, 2023
A low-code platform blending no-code simplicity with full-code power
Get started free
Table of contents

Say no to chaotic work. Automate your tasks now.

Learn how to seamlessly incorporate Mixpanel analytics into your email communication by integrating it with Mailgun. 

This guide will walk you through the steps to set up this powerful no-code automation and leverage it for better insights and more intelligent decision-making.

Mailgun.com is a popular email delivery service used by thousands of projects but lacks advanced analytics capabilities. To gain deeper insights into your clients' behavior, consider using a tool like Mixpanel.com. However, tracking email effectiveness can be a challenge. That's where Latenode comes in.

With Latenode's simple cloud workflow automation, you can easily track the delivery and open rates of emails sent to each specific user on your platform. By measuring email campaigns' success and identifying improvement opportunities, you can enhance your clients' experience and boost engagement with your product.

Create two workflows in Latenode.com

To listen webhook calls from Mailgun.com on Delivery and Open events in latenode.com, you must set up receiving webhooks. Simply click the 'Add New Scenario' button and add the 'HTTP -> Triggers -> Webhook' node to your workflow.

Congratulations! You now have everything you need to integrate Mailgun.com with your workflow in Latenode. To complete the setup, copy the Webhook URL in your Latenode scenario.

To set up webhooks in Mailgun.com, follow these simple steps:

To complete the integration, you must set up webhooks for delivery and open events on Mailgun.com. Here's how you can do it:

  1. Log in to your Mailgun account and navigate the 'Webhooks' tab.
  2. Click the 'Add Webhook' button.
  3. Enter the Webhook URL from your Latenode scenario in the 'URL' field.
  4. In the 'Events' section, select 'Delivered' and 'Opened' from the drop-down menu.
  5. Click 'Save' to apply the changes.

That's it! Mailgun.com will now send webhook calls to your Latenode scenario whenever an email is delivered or opened.

Check incoming data in Latenode

After taking the previous steps, you will start to get data about Delivery and Open events direct in the Latenode workflow:

Let’s prepare the data for sending to Mixpanel

Before sending the data to Mixpanel, you must transform it to match the Mixpanel API documentation. To do this, you can use a JS node in your workflow. Here's how:

  1. Open your Latenode scenario in the workflow editor.
  2. Add a JS node to the scenario.
  1. Click on the JS node to open the JS editor.
  2. Enter the code to transform the incoming data as per the Mixpanel API documentation .
  3. Click 'Save' to apply the changes.

That's it! Your data is ready to be sent to Mixpanel for analysis and insights.

The final code for data transform the Email Delivered event:

let result = [];

let timestamp = Date.now();

let distinct_id = data["{{1.body.`event-data`.`user-variables`.`email_location`}}"] + "_" + data["{{1.body.`event-data`.`user-variables`.`email_to_id`}}"];

let insert_id_hash = data["{{1.body.`event-data`.id}}"];


result.push({

       "event": "Email delivered",

       "properties": {

           "time": timestamp,

           "distinct_id": distinct_id,

           "$insert_id": insert_id_hash

           }

   });


return {

   result

}

Now let’s send data to Mixpanel

Add “HTTP -> HTTP request” node and setup it up as follows

Great, you have successfully integrated Mixpanel analytics with emails sent from Mailgun using Latenode's no-code automation platform. Now you can track your users' email engagement and behavior more effectively and use the insights to improve your service.

With the workflow set up, you can create reports and dashboards in Mixpanel to better understand how your users interact with your service. This can help optimize your email campaigns, improve user engagement, and ultimately grow your business.

Related Blogs