Automation Lab
•
2024-03-11
Build a Gmail Open Tracker with Google Apps Script (GAS)
Estimated Time
15 MIN
Environment
Google Apps Script, Google Sheets
Concept
How it Works
Gmail's built-in read receipts are only available for Workspace accounts. In this lab, we'll build a custom tracking pixel that works for any Gmail account using Google Apps Script.
- Tracking Pixel: A tiny 1x1 transparent image hosted on a GAS Web App.
- Logging: When the recipient opens the email, their GAS logs the event.
01
Step 1 GAS Script
Create a new script at script.google.com and paste this:
function doGet(e) {
var id = e.parameter.id;
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.appendRow([new Date(), id, e.parameter.user_agent]);
var clearGif = "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
return ContentService.createTextOutput("")
.setMimeType(ContentService.MimeType.TEXT)
.append(Utilities.base64Decode(clearGif));
}
Deployment
Deploy as a Web App and set access to "Anyone".
02
Step 2 Usage
Embed the tracking URL in your email's HTML:
<img src="YOUR_WEB_APP_URL?id=RecipientName" width="1" height="1">
Download Full Automation Pack
Get all source codes, advanced configurations, and exclusive troubleshooting guides.
FREE DOWNLOADSecure Verification Required