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 Data 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
- This Integration allows you to track email delivery events like Email Sent, Email Delivered, Email Bounced etc. in Moengage.
- 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 email@example.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 -
- Go to your sendgrid dashboard -> Settings -> Mail Settings -> Event Settings -> Event Webhook and turn it on.
- 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)
- Select the events that you want to send to MoEngage from the Sendgrid dashboard UI as shown below -
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
- 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)
Please note that any delivery feedback or engagement event without this uid field will be rejected by MoEngage.
- 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 -
"name": "John Doe"
"subject": "Hello, World!",
"name": "Mark Smith"
"name": "Mark Smith"
"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 -
The different events that you would be able to see on the MoEngage dashboard are as below -
- Email Sent
- Email Deferred
- Email Dropped
- Email Delivered
- Email Hard Bounced
- Email Soft Bounced
- Email Unsubscribed
- Email Spam
- Email Opened
- 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.