Count the emails of a site over time
get_site_email_stats
Counts the emails a site sent over a period, split into delivered, still pending and failed, with open and click rates and the top links.
totals covers the whole window, with total, delivered, pending and failed, and recipients, the number of sends those messages counted for. days holds one entry per hour, day or month, as interval says, and windowDays says how many days the window spans. Entries with no email come back as zeros, so the list always covers the full window. Test emails are left out, and so are messages removed from the history.
failed gathers every message that did not fully arrive: partly delivered, bounced, marked as spam, rejected or never went out. These are the same counts the Sending view of the site's Insights tab draws, and they count messages, not allowance. One message to five people is a single message here but five sends against the monthly allowance, which is why the totals also carry the recipient count, and get_site_email_usage is the tool for what is left of that allowance.
For open and click tracking, each entry also carries opened and clicked, grouped by when the message was sent. The totals carry trackedDelivered, the messages sent with tracking on that reached at least one recipient, where an open or a click counts as delivered and a later spam report or bounce does not remove the message. They also carry opened and clicked, the tracked messages opened at least once and with at least one link click, and openRate and clickRate, percentages of trackedDelivered that are null while nothing tracked was delivered.
topLinks lists up to 10 links with the most clicks across the window. All of these count messages, never recipients, and opens are approximate because some mail apps load images automatically and others block them. See Read the insights.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
projectId |
string | Yes | The site id. |
period |
string | No | One of day, 24h, 7d, 30d, 90d, 12mo or all. day is today so far, from midnight UTC, 24h is the current hour and the 23 before it, 7d, 30d and 90d are the last 7, 30 and 90 days counting today, 12mo is this month and the 11 before it, and all reaches back to the first record. Defaults to 30d, and is left out when you send from and to. |
from |
string | No | The first day of a custom range as YYYY-MM-DD in UTC, sent together with to. |
to |
string | No | The last day of a custom range as YYYY-MM-DD in UTC, included in the range and sent together with from. |