Email Events Integration with Sendgrid

Introduction

At times, you may want to send emails from Sendgrid Email API directly instead of sending emails via a campaign on MoEngage dashboard. This is generally the recommended approach for your transactional use-cases like payment updates, OTP etc.

The email events integration with Sendgrid allows you to capture the delivery feedback and engagement events in MoEngage for such emails sent directly through Sendgrid Email API.

Scope of Integration

  1. This Integration allows you to track email delivery events like Email Sent, Email Delivered, Email Bounced etc. in Moengage.
  2. This Integration allows you to track email engagement events like Email Opened, Email Clicked, Email Spam etc. in Moengage.

Enabling the Sendgrid Data Integration for your MoEngage account

This integration can only be enabled on demand. If you have a use-case to forward email events from Sendgrid to MoEngage for your transactional emails, you can reach out to your Moengage Customer Success Manager or write to support@moengage.com.

Please note that this is only required to see email delivery and engagement events on MoEngage dashboard for emails that you send directly using sendgrid email API. For emails sent via MoEngage campaigns, this is not required.

Configurations on the Sendgrid Dashboard

To setup this data integration, please follow the below steps -

  1. Go to your sendgrid dashboard -> Settings -> Mail Settings -> Event Settings -> Event Webhook and turn it on.

  2. Add webhook URL - https://api.moengage.com/v1/deliveryfeedback/sendgrid/<your_app_key> on the sendgrid dashboard where app_key is the app_key of your MoEngage account and available on your MoEngage dashboard here. (Settings -> App Settings)

  3. Select the events that you want to send to MoEngage from the Sendgrid dashboard UI as shown below - 
    Screen_Shot_2020-08-12_at_11.37.45_AM.png

 

Changes to your mail send API request (Sendgrid)

To capture the delivery feedback and engagement events from Sendgrid, there are a few things to note here

  1. When sending emails via Sendgrid API directly, it is mandatory that you send a key value pair for uid under custom_args. The value of uid should be the same as the value of the Client_Id or ID on the MoEngage user profile (see reference below)

    Screen_Shot_2020-08-12_at_11.58.45_AM.png

    Please note that any delivery feedback or engagement event without this uid field will be rejected by MoEngage.

  2. To track category, you need to add the key - "categories" in your sendgrid email API request. This is not mandatory.

A sample Sendgrid Email API request with uid and category would be like below -

{
"personalizations": [{
"to": [{
"email": "johndoe@example.com",
"name": "John Doe"
}],
"subject": "Hello, World!",
"categories": [
"signupOTP",
"Internal"
],
"custom_args": {
"uid": "Unique_user_id"
}
}],
"from": {
"email": "marksmith@sample.com",
"name": "Mark Smith"
},
"reply_to": {
"email": "marksmith@sample.com",
"name": "Mark Smith"
},
"content": [{
"type": "text/plain",
"value": "Sample email text"
}]
}

Events tracked in MoEngage

Once the configurations are done on the Sengrid dashboard and you are passing the mandatory uid parameter in your email API request to Sendgrid, you will start seeing events on MoEngage dashboard user profile as shown below -

Screen_Shot_2020-08-12_at_11.58.45_AM.png

The different events that you would be able to see on the MoEngage dashboard are as below - 

  1. Email Sent
  2. Email Deferred
  3. Email Dropped
  4. Email Delivered
  5. Email Hard Bounced
  6. Email Soft Bounced
  7. Email Unsubscribed
  8. Email Spam
  9. Email Opened
  10. Email Clicked

Please note that if we are unable to find a user with the uid present in the event request from Sendgrid, MoEngage will create a new user. This might affect your stats and other things so always ensure the send a correct value for uid.

 

Was this article helpful?
0 out of 0 found this helpful