如何使用 API 从 Marketo 获取电子邮件营销洞察数据?

How to fetch email marketing insights data from Marketo using API?

I am trying to fetch "Email Performance Report" from the platform using API to analyze the KPI's like CTR etc by type of the email (newsletter,email marketing etc).

I went through the documentation, however I didn't find endpoint from which I can fetch the same.

有谁知道是否有办法获取这些信息?

没有直接查询报告的端点。然而,好消息是,构成“电子邮件性能报告”的“事物”,即:电子邮件发送、退回、打开和点击都可以通过 API.
查询 这意味着您必须自己构建报告,但您可以获取要处理的数据集。

这些“东西”被称为 activity 类型 (activity 在潜在客户上测量)并且可以通过查询 Get Lead Activities endpoint, which is also mentioned as the Query 在 API 文档中。
它位于 GET /rest/v1/activities.json url 并且您必须传递 nextPageTokenactivityTypeIds 作为查询参数。

nextPageToken 表示日期时间。该日期之后的活动将通过电话返回。要获得一个,您必须致电 GET /rest/v1/activities/pagingtoken.json, where you have to specify the earliest datetime to retrieve activities from. See more about Paging Tokens

要计算出activityTypeIds的值,首先需要获取您感兴趣的activity类型的内部ID。在为此,您必须查询 GET /rest/v1/activities/types.json 端点并查找 activity 类型 s 和 names像 Send EmailEmail DeliveredEmail BouncedUnsubscribe EmailOpen EmailClick Email。 (我不知道这些 ID 是否在实例之间发生变化,但在我们的实例中,这些 ID 是从 #6 到 #11)。

一旦你掌握了所有这些位,你就可以这样提出你的请求:

GET https://<INSTANCE_ID>.mktorest.com/rest/v1/activities.json?activityTypeIds=<TYPE_ID>&nextPageToken=<NEXTPAGE_TOKEN>&access_token=<ACCESS_TOKEN>

它给出的结果是一个包含如下项目的数组。可以根据 primaryAttributeValue 属性 将项目过滤到特定的电子邮件,并进行相应的进一步处理。

{
    "id":7370416,
    "marketoGUID":"7170506",
    "leadId":291305,
    "activityDate":"2017-12-17T00:00:00Z",
    "activityTypeId":11,// #11 = `Click Email`
    "campaignId":1790,
    "primaryAttributeValueId":1638,
    "primaryAttributeValue":"EMAIL_NAME",// Name of the Email as seen in Marketo
    "attributes":[
        // …
    ]
}