Table of Contents:
Table of Contents minLevel 2
Intro
Info |
---|
This is the primary aggregated reports API method. In fact, all the Analytics reports one finds in the Ongage UI, such as the Aggregate report, Matrix report, Transactional, etc. are all generated with this API method. |
Note: Notice that in each API call you must provide the List ID that you are working on, otherwise the default List ID will be used.
Methods Summary
POST /api/reports/query
Description
This method fetches reports data from "mailing_data". Those residing under the Analytics in the UI of your account.
...
Ongage\ResourceBundle\Model\Exception\InvalidData
Examples
Example - Retrieve Stats from All Lists
...
Code Block |
---|
{ "select":[ "mailing_name", [ "MAX(`stats_date`)", "stats_date" ], "sum(`sent`)", "sum(`success`)", "sum(`failed`)", "sum(`opens`)", "sum(`unsubscribes`)", "sum(`complaints`)", "sum(`clicks`)", "sum(`unique_clicks`)", "list_id" ], "from":"mailing", "group":[ "list_id", "mailing_id" ], "list_ids" : "all", "get_extra_conversion_points":true, "filter":[ [ "mailing_type", "!=", "transactional" ], [ "stats_date", ">=", "2015-05-01" ], [ "stats_date", "<=", "2015-06-20" ] ] } |
Example - Retrieve all Campaigns in Last 30 Days
POST URL: https://api.ongage.net/api/reports/query
Code Block |
---|
{ "list_ids":[ "1111" ], "select":[ "mailing_name", "mailing_id", "stats_date" ], "filter":[ [ "stats_date", ">=", "2016-09-22" ], [ "schedule_date", ">=", "2016-09-22" ] ], "from":"mailing", "group":[ "mailing_id" ] } |
Example - Retrieve Stats Grouped by Campaign/Day/Domain
POST URL: https://api.ongage.net/api/reports/query
Code Block |
---|
{ "select":[ "mailing_name", [ "MAX(`stats_date`)", "stats_date" ], "isp_name", "sum(`sent`)", "sum(`success`)", "sum(`failed`)", "sum(`opens`)", "sum(`unique_opens`)", "sum(`unsubscribes`)", "sum(`complaints`)", "sum(`clicks`)", "sum(`unique_clicks`)" ], "from":"mailing", "group":[ "mailing_id", [ "stats_date", "day" ], "isp_id" ], "order":[ [ "stats_date", "desc" ] ], "filter":[ [ "is_test_campaign", "=", 0 ], [ "stats_date", ">=", "2015-01-01" ] ], "calculate_rates":true } |
Example - Produce Matrix Report Grouped by ESP
POST URL: https://api.ongage.net/api/reports/query
Code Block |
---|
{
"filter":[
[
"is_test_campaign",
"=",
0
],
[
"email_message_type",
"=",
"email_message"
],
[
"stats_date",
">=",
1615919400
],
[
"stats_date",
"<=",
1617215399
]
],
"select":[
[
"MAX(`stats_date`)",
"stats_date"
],
[
"MAX(`delivery_timestamp`)",
"delivery_timestamp"
],
"sum(`targeted`)",
"sum(`sent`)",
"sum(`success`)",
"sum(`failed`)",
"sum(`hard_bounces`)",
"sum(`soft_bounces`)",
"sum(`opens`)",
"sum(`unique_opens`)",
"sum(`clicks`)",
"sum(`unique_clicks`)",
"sum(`unsubscribes`)",
"sum(`complaints`)",
"esp_name_title",
"isp_name_or_others",
"sum(`post_back_clicks`)"
],
"from":"mailing",
"order":[
[
"MAX(`delivery_timestamp`)",
"desc"
]
],
"group":[
"esp_connection_id",
]
} |
Example - Produce Matrix Report Grouped by Domain
POST URL: https://api.ongage.net/api/reports/query
Code Block |
---|
{ "filter":[ [ "is_test_campaign", "=", 0 ], [ "email_message_type", "=", "email_message" ], [ "stats_date", ">=", 1615919400 ], [ "stats_date", "<=", 1617215399 ] ], "select":[ [ "MAX(`stats_date`)", "stats_date" ], [ "MAX(`delivery_timestamp`)", "delivery_timestamp" ], "sum(`targeted`)", "sum(`sent`)", "sum(`success`)", "sum(`failed`)", "sum(`hard_bounces`)", "sum(`soft_bounces`)", "sum(`opens`)", "sum(`unique_opens`)", "sum(`clicks`)", "sum(`unique_clicks`)", "sum(`unsubscribes`)", "sum(`complaints`)", "esp_name_title", "isp_name_or_others", "sum(`post_back_clicks`)" ], "from":"mailing", "order":[ [ "MAX(`delivery_timestamp`)", "desc" ] ], "group":[ "isp_id" ] } |
Example - Analytics Report Using Complex Grouping
POST URL: https://api.ongage.net/<list_id>/api/query
This report includes both Events and Campaigns Stats in the same report.
Code Block |
---|
{ "select": [ "mailing_type", "event_id", "mailing_id", "mailing_instance_id", "mailing_name", "event_name", "email_message_id", "email_message_name", "sum(`sent`)", "sum(`success`)", "sum(`opens`)", "sum(`clicks`)", "sum(`hard_bounces`)", "sum(`soft_bounces`)", "sum(`unsubscribes`)", "sum(`complaints`)" ], "filter": [ [ "stats_date", ">=", "2015-07-01" ] ], "from": "mailing", "group": [ "mailing_type", "event_id", "mailing_id", "mailing_instance_id", "mailing_name", "event_name", "email_message_id", "email_message_name" ], "order": [] } |
Example - Get link stats of specific Campaign
POST URL: https://api.ongage.net/<list_id>/api/reports/query
...