-
Notifications
You must be signed in to change notification settings - Fork 69
Stats
Igor Balos edited this page Oct 3, 2018
·
5 revisions
You can retrieve many different statistics by API. Here are couple of examples on how statistics retrieval can be used.
For these API requests you will need to use a server API token. Once you obtain it, you will need to use server API client.
server_token = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
client = Postmark::ApiClient.new(server_token)
Retrieve the total number of Sent, Opened, Bounced, etc emails for the time period.
client.get_stats_totals(tag: 'welcome', fromdate: '2015-09-01', todate: '2015-09-30')
# => { :sent=>5234, :bounced=>35 ... }
The #get_stats_counts
method takes two arguments:
- symbol for the kind of stat to get:
:sends
,:bounces
,:spam
,:tracked
, and:opens
- optional hash for arguments:
:tag
,:fromdate
,:todate
, and:type
client.get_stats_counts(:sends, fromdate: '2015-09-15')
{
:days => [
{:date => "2015-09-15", :sent => 9 },
{:date => "2015-09-16", :sent => 3 },
{:date => "2015-09-17", :sent => 7 },
{:date => "2015-09-18", :sent => 1 }
],
:sent => 20
}
The :type
argument can be used when getting :opens
stats to get specific opens stats:
-
:platforms
- Break down opens by desktop, mobile, or webmail. -
:emailclients
- Break down opens by email clients. -
:readtimes
- Break down opens by how long emails were read.
client.get_stats_counts(:opens, fromdate: '2015-09-15', type: :emailclients)
{
:days => [
{:date => "2015-09-15", :gmail => 3 },
{:date => "2015-09-16", :gmail => 1 },
{:date => "2015-09-17", :gmail => 5 }
],
:gmail => 9
}
For additional information about the capabilities of the Postmark API, see Postmark Developers Documentation.
- Email sending
- Test email sending
- Bounces
- Templates
- Templates push
- Server
- Servers
- Message Streams
- Webhooks
- Messages
- Domains
- Sender Signatures
- Stats
- Trigger Tags
- Suppressions
- Data Removals
- Trigger Inbound Rules
- Parsing Inbound
- Using Postmark with Mail library
- Accessing Postmark Message ID
- Error Handling
- Integration Testing
- Troubleshooting
- Known issues and how to resolve them