Skip to content

Instantly share code, notes, and snippets.

Host: https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com
POST /interaction/v1/events
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
{
"ContactKey": {{emailAddress}},
"EventDefinitionKey": {{WaitUntilEventActivityAPIkey}},
"Data": {
"email": {{emailAddress}},
Host: https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com
POST /interaction/v1/events
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN
{
"ContactKey": {{emailAddress}},
"EventDefinitionKey": {{EventDefinitionKey}},
"Data": {
"email": {{emailAddress}},
%%[
set @CustomerID = AttributeValue("CustomerID")
set @rows = LookupRows("Orders","CustomerID",@CustomerID)
set @rowCount = RowCount(@rows)
for @counter = 1 to @rowCount do
set @row = row(@rows,@counter)
set @orderItem = field(@row,"Item")
]%%
select distinct
jobid,
ListID,
BatchID,
subscriberid,
count(distinct url) AS URLs
from _click
group by subscriberid, jobid, ListID, BatchID
select
jobid,
ListID,
BatchID,
subscriberid,
count(subscriberid) AS Clicks
from _click
group by subscriberid, jobid, ListID, BatchID
select
jobid,
ListID,
BatchID,
subscriberid,
count(subscriberid) AS Opens
from _open
group by subscriberid, jobid, ListID, BatchID
select
s.subscriberkey
from _sent s
left join _open o
on s.jobid = o.jobid and s.listid = o.listid and s.batchid = o.batchid and s.subscriberid = o.subscriberid and o.isunique = 1
left join _click c
on s.jobid = c.jobid and s.listid = c.listid and s.batchid = c.batchid and s.subscriberid = c.subscriberid and c.isunique = 1
SELECT contact.Email,
contact.Id
FROM /*data extension name*/ contact
INNER JOIN (
SELECT Email,
MAX(Id) AS Id
FROM /*data extension name*/
GROUP BY Email
) aggr
ON aggr.Email = contact.Email AND aggr.Id = contact.Id
SELECT contact.Email,
contact.Id
FROM ent.Contact_Salesforce contact
INNER JOIN (
SELECT Email,
MAX(Id) AS Id
FROM ent.Contact_Salesforce
GROUP BY Email
) aggr
ON aggr.Email = contact.Email AND aggr.Id = contact.Id