APIs & Integrations

AEckert
Participant

Determining if an Email Address was sent an email or not

I've been tasked with emails we've sent over the past few years through hubspot as well as returning every email address those emails went to.
I'm able to get the emails no problem, as well as the groups of email addresses that each email is associated with, but the issue is that the groups don't determine which email addresses had opted out and had not had an email sent to them.

It messes up the statistics because the email might return that 100 emails were sent, but there might be 120 people in the group that was associated with the email. I need to determine who the 20 email addresses are in the group of 120 that didn't get emails, and not record their data.

To get this info, I called "/marketing/v3/emails/?includeStats=true" as well as a timeframe, looping through each return statement and using "after"

Once I have that info, I call "/crm/v3/lists/[listId]/memberships" based on what lists where included in the email. This returns to me each "group" of email addresses that should have received this email.

Finally, I call "/crm/v3/objects/contacts/[recordId]" for each recordID in "/crm/v3/lists/[listId]/memberships"

This in theory gets me all the data I need, except it gives me extra email addresses that have chosen to opt out. I have verified that my thought process is correct by going to HubSpot -> Marketing -> Emails and verifying that a certain email only sent out what it said it sent out, regardless of the group size (if we continue our example, I can see 100 emails and not the 120 of the group returned by the API). In theory, I could do a process of eliminiation for each email to determine which 20 email addresses (or many many more in most cases) had opted out of receiving the email. 

I've tried the endpoints "/email/public/v1/events?recipient=[emailAddress]&eventType=UNSUBSCRIBED" as well as "/communication-preferences/v3/status/email/[emailAddress]" but both return incorrect data, since I have a test sample of email addresses that I'm certain hadn't received emails and had opted out. 

Is there anyone that can help point me in the right direction?

2 Replies 2
Humashankar
Key Advisor

Determining if an Email Address was sent an email or not

Hi @AEckert 

To gain a deeper understanding of email interactions, leverage the /email/public/v1/events endpoint, which offers valuable insights into email send events.

Despite previous issues, revisit this endpoint and filter by event type to focus on specific interactions such as "SEND", "OPEN", "CLICK", or "BOUNCE". These events provide granular information about how recipients engage with your emails.

In addition, consider the event timestamps to correlate email sends with list memberships and opt-out status, allowing you to accurately determine which contacts received the email and their subsequent actions

 

Hope this helps - Happy to help further!!
Thank you very much and have a great one!
Warm regards

Humashankar VJ
HubSpot Enthusiast and Key Advisor | Engineering Manager
AEckert
Participant

Determining if an Email Address was sent an email or not

Hey, thanks for replying!
I tried it and got some data back when using /email/public/v1/events with the parameter "eventType=SENT" and it gave me a list of every email associated with an email address. I can use this list of emails we've sent to that address to determine what all emails we've sent with each person. My other issue now is: none of the values that the API returned have an ID that relates to any of the ID's on the initial endpoint (/marketing/v3/emails). The only way to link the items is through the "subject", but that's not necessarily reliable, since some emails have been sent with the same subject. Is there a way to link the emailCampaignId in the /email/public/v1/events endpoint to something within the /marketing/v3/emails endpoint?

Thanks!

0 Upvotes