Skip to content

Instantly share code, notes, and snippets.

View ampscript-loops.html
%%[
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")
]%%
View total-number-urls.sql
select distinct
jobid,
ListID,
BatchID,
subscriberid,
count(distinct url) AS URLs
from _click
group by subscriberid, jobid, ListID, BatchID
View total-number-clicks.sql
select
jobid,
ListID,
BatchID,
subscriberid,
count(subscriberid) AS Clicks
from _click
group by subscriberid, jobid, ListID, BatchID
View total-number-opens.sql
select
jobid,
ListID,
BatchID,
subscriberid,
count(subscriberid) AS Opens
from _open
group by subscriberid, jobid, ListID, BatchID
View joining-data-views.sql
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
View deduplicate_subscribers.sql
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
View deduplicate_synched_Contacts.sql
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
View batchcontactevents.json
Host: https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com
POST /interaction-experimental/v1/batchcontactevents
Content-Type: application/json
Authorization: Bearer YOUR_V1_ACCESS_TOKEN
{
"EventDefinitionKey":"{{API entry event key}}",
"BatchId":"",
"RecordCount":2,
View campaign-journey-payload.json
*****2020-11-12 16:51:04.337|HTTP RESPONSE|"6ffc2d53-c97e-4a89-bd66-535cxxxxx"
*****2020-11-12 17:02:29.36|HTTP CALLOUT|FireJourneyBuilderEvent
*****2020-11-12 17:02:29.46|HTTP REQUEST|https://mcxxxxx.rest.marketingcloudapis.com/interaction-experimental/v1/batchcontactevents
{
"EventDefinitionKey":"SalesforceObjcbd44d55f8f9df29b0f5631xxxxxx",
"ContactPersonType":"CampaignMember",
"CallerSystemName":"Salesforce",
"BatchId":"",
"RecordCount":2,
View formAMPscriptMultiSelectPicklist.html
<script runat="server">
Platform.Load("Core","1.1.1");
try{
</script>
%%[
IF RequestParameter("submitted") == true THEN
SET @preferences = CONCAT(
Iif(RequestParameter("newsletters") == "on", "Newsletters;", ""),
Iif(RequestParameter("events") == "on", "Events;", ""),