Programmatically accessing data from Dynamics Marketing Insights

insightsRecently I got a question from one of the customers on how to extract data from Dynamics Marketing Insights as there is no export functionality so far. They just wanted to extract data as CSV or Excel and send this data to some other people for analysis. In this article, we will go through some undocumented Dynamics Marketing APIs, which can help you with this task.

Disclaimer: Some of the APIs provided in this article are not officially supported so that they might be changed without prior notice. Please use them on your own risk.

First of all, there are some public APIs which you can easily access. Currently, you can retrieve interactions from the contact point of view. Check the following article for more information: Retrieve interactions for a contact using code

In this article, I would like to focus on Insights from e-mail point of view. As you know, we have several types of widgets. The first type is the widget with just some values.


The second type is a widget of type grid. Here is how it looks like:


Both widgets are accessible through different APIs. Let’s focus on the lists as usually, these reports provide the most crucial information. To get information from the widget of the type grid, you should call msdyncrm_ListWidgetData organizational request. Of course, there are a bunch of parameters available which can help you to configure the request. Let’s check one request to get information about delivered e-mails. Example of that grid you can see in the picture below:


Now let’s check the code which can extract data from this grid.

OrganizationRequest request = new OrganizationRequest("msdyncrm_ListWidgetData"); request.Parameters.Add("WidgetRequest", 
    "{\"WidgetId\":" +
     "\"MessageEmailDeliveredByContactList\"," +
     "\"Top\":25," +
     "\"SkipToken\":\"\"," +
     "\"LanguageId\":\"1033\"," +
     "\"OffsetFromUtcInMinutes\":120," +
     "\"Filter\":" +
     	" {\"DateFrom\":\"2019-07-25T09:57:39.486Z\"," +
     	" \"DateTo\":\"2019-08-25T09:57:39.486Z\"," +
         " \"Properties\":[{\"Name\":\"MessageId\"," +
         " \"Value\":\"47bd8737-f67a-e911-a972-000d3aba0352\"}]}}");

 var response = _service.Execute(request);

As you see, we have a parameter called WidgetId. This parameter is used to define which widget should be applied. We have plenty of different widgets which you might use. Here are some of the available:

  • MessageEmailClickedByContactList
  • MessageEmailDeliveredByContactList
  • MessageEmailForwardedByContactList
  • MessageEmailOpenedByContactList
  • MessageEmailSendingFailedByContactList
  • MessageEmailSentByContactList
  • MessageEmailBlockedByContactList
  • MessageEmailSoftBouncedByContactList
  • MessageEmailHardBouncedByContactList
  • MessageEmailFeedbackLoopList
  • MessageEmailSubscriptionSubmitList
  • LinkAnalysisList

Here is how response for LinkAnalysisList might look like:


In case of questions please don’t hesitate to contact me.

4 thoughts on “Programmatically accessing data from Dynamics Marketing Insights

  1. Hi Pavel,

    This article is really helpful.

    From code you posted, it seems that it could also be retrieved with a web api request, and I thought I was close to get result, just wonder what request format would be.

    When I try to execute it in crm, it will throw error that start node object value is invalid in WidgetRequest, any idea would be appreciated if you could check it.

    var data = {
    “WidgetRequest”: {
    “WidgetId”: “MessageEmailClickedByContactList”,
    “Top”: 25,
    “SkipToken”: “”,
    “LanguageId”: “1033”,
    “OffsetFromUtcInMinutes”: 120,
    “Filter”: {
    “DateFrom”: “2019-10-20T09:57:39.486Z”,
    “DateTo”: “2019-10-25T09:57:39.486Z”,
    “Properties”: [{
    “Name”: “MessageId”,
    “Value”: “47bd8737-f67a-e911-a972-000d3aba0352”

    var req = new XMLHttpRequest();“POST”, Xrm.Page.context.getClientUrl() + “/api/data/v9.0/msdyncrm_ListWidgetData”, false);
    req.setRequestHeader(“OData-MaxVersion”, “4.0”);
    req.setRequestHeader(“OData-Version”, “4.0”);
    req.setRequestHeader(“Accept”, “application/json”);
    req.setRequestHeader(“Content-Type”, “application/json; charset=utf-8”);
    req.onreadystatechange = function() {
    if (this.readyState === 4) {
    req.onreadystatechange = null;
    if (this.status === 204 || this.status === 200) {
    } else {
    var error = JSON.parse(this.response).error;
    Xrm.Utility.alertDialog(“Error in Action: ” + error.message);

    1. Hi!

      I just created a sync call and was able to execute it from the chrome console. I think you have some mistakes in json formatting. Please check below the example. Don’t forget to replace your_crm_url and your_message_id placeholders.

      var actionName = “msdyncrm_ListWidgetData”;
      var data = {
      WidgetRequest: ‘{“WidgetId”:”InteractionsTimelineEmail”,’+
      var req = new XMLHttpRequest();“POST”, “https://your_crm_url/api/data/v9.0/” + actionName, false);
      req.setRequestHeader(“Accept”, “application/json”);
      req.setRequestHeader(“Content-Type”, “application/json; charset=utf-8”);
      req.setRequestHeader(“OData-MaxVersion”, “4.0”);
      req.setRequestHeader(“OData-Version”, “4.0”);

      Hope it helps!

Leave a Reply

Your email address will not be published. Required fields are marked *