Skip to content

Instantly share code, notes, and snippets.

POST URL - https://xxxxxx.auth.marketingcloudapis.com/v2/token
Header :
Key - Content-Type
Value - application/json
Body:
{
"grant_type": "client_credentials",
"client_id": "Your Client Id",
<!DOCTYPE html>
<html>
<body>
%%[
IF RequestParameter("submitted") == "submitted" Then
]%%
<script runat="server">
Platform.Load("Core", "1");
try {
<!DOCTYPE html>
<html>
<body>
<h2>Sign Up Form</h2>
<form action="%%=RequestParameter('PAGEURL')=%%" method="POST">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="firstname" value=""><br><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lastname" value=""><br><br>
<label for="lname">Email:</label><br>
<!DOCTYPE html>
<html>
<body>
%%[
IF RequestParameter("submitted") == "submitted" Then
VAR @httppost,@apiid,@apistatusCode,@apiresponse,@apitoken
SET @apiid = '{"client_id": "client_id","client_secret": "client_secret", "grant_type": "client_credentials","account_id": "MID"}' /* Forming up the string for getting the access token */
SET @httppost = HTTPPost2("https://xyz.auth.marketingcloudapis.com/v2/token","application/json",@apiid,true,@apiresponse,@responseRows) /* Making a POST call to get access token */
IF(@httppost == "200") Then /* If status is Sucess */
set @rows = BuildRowsetFromString(@apiresponse,'"') /* Split the rows based on '"' string */
%%[
VAR @httppost,@apiid,@apistatusCode,@apiresponse,@apitoken
SET @apiid = '{"client_id": "client_id","client_secret": "client_secret", "grant_type": "client_credentials","account_id": "MID"}' /* Forming up the string for getting the access token */
SET @httppost = HTTPPost2("https://xyz.auth.marketingcloudapis.com/v2/token","application/json",@apiid,true,@apiresponse,@responseRows) /* Making a POST call to get access token */
IF(@httppost == "200") Then /* If status is Sucess */
set @rows = BuildRowsetFromString(@apiresponse,'"') /* Split the rows based on '"' string */
set @rowCount = rowCount(@rows)
if @rowCount > 0 then
for @i = 1 to @rowCount do
var @apitoken
Select T.[First Name], T.[Last Name], T.Email, dateadd(second,Tz.Time_Difference_in_Seconds_for_SFMC, DATEADD(YEAR,-(DATEDIFF(YEAR, getdate(), DateofBirth)), T.DateofBirth)) as [Local Time], T.DateofBirth, T.Country_code
from [Test Time Record] as T
JOIN [Time Zone] as Tz
on T.Country_code = Tz.Country_code
%%[
set @Country_ISO = AttributeValue("Country_ISO")
set @Subject = Lookup("Test Dynamic Email Translation","Subject","Country_ISO",@Country_ISO)
set @preheader = Lookup("Test Dynamic Email Translation","Preheader","Country_ISO",@Country_ISO)
set @Header_Image = Lookup("Test Dynamic Email Translation","Header Image","Country_ISO",@Country_ISO)
set @Header_Text = Lookup("Test Dynamic Email Translation","Header Text","Country_ISO",@Country_ISO)
set @CTA_Text = Lookup("Test Dynamic Email Translation","CTA Text","Country_ISO",@Country_ISO)
set @CTA_Link = Lookup("Test Dynamic Email Translation","CTA Link","Country_ISO",@Country_ISO)
]%%
@naveenvm93
naveenvm93 / Integrate-Wix-With-Salesforce-Marketing-Cloud.HTML
Created November 2, 2019 09:52
Integrate-Wix-With-Salesforce-Marketing-Cloud
%%[ var @contactform,@Email, @formEmpty
set @contactform = "false"
set @formEmpty = "false"
if RequestParameter("submitted") == "submitted"
then
set @contactform = "True"
Set @Email = RequestParameter("emailaddress")
IF NOT EMPTY(RequestParameter("emailaddress"))
THEN Set @UpsertData = UpsertDE('Contact_form','1','emailaddress',@Email,'submitteddate',NOW()) Else Set @formEmpty = "True" ENDIF
ENDIF]%%
@naveenvm93
naveenvm93 / SFMC-Journey-Email-Tracking
Created October 11, 2019 09:23
This is used to track Journey Emails from Google Sheets
<script runat="server">
Platform.Load("Core", "1.1.1");
try {
var paramtskey = Request.GetQueryStringParameter("tskey");
var parammetric = Request.GetQueryStringParameter("metric");
if (parammetric === "all") {
var tsd = TriggeredSend.Init(paramtskey);
var triggerSendTracking = tsd.Tracking.Retrieve();
var tsTracking = Stringify(triggerSendTracking);
%%[
if RequestParameter("submitted") == "submitted" then
Set @EmailAddr = RequestParameter("Email")
Set @FirstName = RequestParameter("FirstName")
Set @LastName = RequestParameter("LastName")
/* Trigger Send Object Creation */
SET @ts = CreateObject("TriggeredSend")
SET @tsDef = CreateObject("TriggeredSendDefinition")
SET @ts_subkey = @EmailAddr