When Doctors Stop Opening Emails: A SQL-Powered Non-Engagement Alert System for Pharma Reps
Team Genetrix
•
April 2026
•
8 min read
In pharmaceutical marketing, email engagement data is not just a marketing metric — it’s a sales signal. When a Healthcare Professional (HCP) consistently ignores your emails, it likely means one of two things: they’re not interested in the content, or they’ve mentally disengaged from the relationship. Either way, the right response is not to send another email. It’s to send a person.
A healthcare client came to us with a specific requirement: they needed their medical representatives to know which HCPs had stopped engaging with email communications — not just with low engagement in general, but with three consecutive emails specifically — so reps could prioritise in-person visits and understand the disconnect.
The solution we built tracks email sequences per HCP, applies a 7-day engagement window per send, detects consecutive non-opens, and automatically alerts the assigned medical rep in Sales Cloud — entirely automated, no manual reporting required.
The Business Rules — Where the Complexity Lives
The technical challenge of this solution is almost entirely in correctly implementing the business rules. The rules sound simple in plain English; they are surprisingly intricate in SQL.
The rules were:
- Track email sends per HCP across a defined journey (up to 6 emails in sequence).
- An email only counts as “opened” if the open event occurs within 7 days of the send date. Opens after day 7 are counted as non-opens.
- If an HCP fails to open 3 consecutive emails, set a checkbox on their Sales Cloud Contact record to alert their assigned rep.
- If the HCP opens any email within a sequence — even after two consecutive non-opens — the counter resets to zero.
- The checkbox is automatically disabled after the rep notification fires, allowing the system to detect the next consecutive non-engagement window independently.
The Architecture: Marketing Cloud Does the Heavy Lifting
The solution is split across two platforms, but the intelligence lives almost entirely in Marketing Cloud.
Marketing Cloud: SQL Sequence Tracking
A scheduled SQL automation runs regularly and evaluates the email open history per HCP contact. It pulls from Marketing Cloud’s _Sent and _Open Data Views, assigns sequence numbers per contact, applies the 7-day open window filter, and checks for consecutive non-open triplets.
SQL — Sequence Tracking With 7-Day Open Window
-- Step 1: Assign sequence numbers and evaluate opens within 7 days SELECT s.SubscriberKey, s.JobID, s.EventDate AS SendDate, ROW_NUMBER() OVER ( PARTITION BY s.SubscriberKey ORDER BY s.EventDate ) AS EmailSeq, CASE WHEN o.SubscriberKey IS NOT NULL AND DATEDIFF(day, s.EventDate, o.EventDate) <= 7 THEN 1 ELSE 0 END AS OpenedInWindow FROM _Sent s LEFT JOIN _Open o ON s.SubscriberKey = o.SubscriberKey AND s.JobID = o.JobID WHERE s.EventDate >= DATEADD(day, -90, GETDATE())
SQL — Detect 3 Consecutive Non-Opens Using LAG()
-- Step 2: Flag contacts with 3 consecutive non-opens SELECT SubscriberKey FROM ( SELECT SubscriberKey, EmailSeq, OpenedInWindow, LAG(OpenedInWindow, 1) OVER ( PARTITION BY SubscriberKey ORDER BY EmailSeq ) AS PrevOpen1, LAG(OpenedInWindow, 2) OVER ( PARTITION BY SubscriberKey ORDER BY EmailSeq ) AS PrevOpen2 FROM EmailSequenceDE ) x WHERE OpenedInWindow = 0 AND PrevOpen1 = 0 AND PrevOpen2 = 0
When the query identifies contacts with 3 consecutive non-opens, it updates a Contact record in Salesforce via the Marketing Cloud-Salesforce connector — setting the NonEngagementFlag__c checkbox to true.
Sales Cloud: Rep Notification and Auto-Reset
In Salesforce, a Flow triggers on the checkbox update. It sends an internal email notification to the specific medical rep assigned to that HCP contact — not a broadcast to all reps, only the rep responsible for that relationship. After the notification fires, the Flow automatically resets the checkbox to false, enabling the system to detect the next consecutive non-engagement window independently.
Solution Logic Summary
- 7-day open window — opens after 7 days from send are counted as non-opens; eliminates noise from late inbox-cleaning opens.
- Consecutive tracking — counter resets on any open; only genuine sequential disengagement triggers an alert.
- Auto-reset checkbox — after each alert, the flag resets so future non-engagement windows are detected independently.
- Rep-specific alerts — notifications go only to the assigned rep for each HCP, not to a general team inbox.
- Marketing Cloud handles the intelligence — Sales Cloud only receives the final flag; all sequence logic lives in SQL.
Frequently Asked Questions
This adds complexity that was scoped but not implemented in the initial phase. Tracking consecutive non-engagement across overlapping journeys requires deduplicating sends per contact across journey IDs and evaluating sequences per journey separately. It’s technically feasible but significantly increases SQL complexity. In the initial implementation, tracking was journey-specific.
The client’s business team defined this based on their understanding of HCP email behavior — a medical professional who opens an email more than a week after receiving it is unlikely to act on it commercially. The 7-day window can be adjusted in the SQL query based on your engagement data and business requirements.
The solution was implemented for 6 specific journey types for this client. For orgs with many overlapping journeys and high contact overlap, the SQL query complexity grows and execution time increases. For very large implementations, consider pre-aggregating engagement data into a summary DE updated daily rather than querying Data Views directly on each run.
Building engagement intelligence for pharma or healthcare?
Genetrix designs and implements custom SQL-driven engagement tracking, rep alert systems, and Sales Cloud + Marketing Cloud integrations for regulated industries. Let’s build something that actually moves the needle for your field teams.
© 2026 Genetrix Technology · Salesforce Consulting Partner · Pune, India & Las Vegas, US
Published: April 2026 · Category: Marketing Cloud · SQL · Healthcare