So far, we have discussed the architecture of our email sender and how we can build a scalable system which can send emails in large volumes.
Now, it's time to track those emails. Let's build and code a program that can track the email open rate, location, IP, device, that is, computer, laptop or phone, and agent, that is, browser.
We are also going to insert that data in the MongoDB database or Cosmos DB.
In the last section, we added the tracking code, which was an image tag using our API call as its source, into the email. Our API call is going to return the image.
Let's develop a sample code which will do the same thing.
Initiate a new Node.js project and install the following dependency:
npm i --S express
Here is the sample code of the API:
const express = require('express'); const app = express(); app.get('/api/track',function(req,res) { console.log('tracking code'+JSON.stringify(req.query)); // sending the image back. var buf = new...