Skip to content

Instantly share code, notes, and snippets.

SELECT
o.SubscriberKey,
ea.Gender
FROM _Open o
INNER JOIN ENT._EnterpriseAttribute ea ON o.SubscriberID = ea._SubscriberID
WHERE ea.Gender = 'Female'
AND o.EventDate > dateadd(d,-7,getdate())
%%[
var @email, @skey
set @skey = AttributeValue("_subscriberkey")
set @email = Lookup("_Subscribers","EmailAddress","SubscriberKey", @skey)
]%%
Email Address: %%=v(@email)=%%
%%[
VAR @subscriberkey, @email, @firstname, @lastname
SET @subscriberkey = _subscriberkey
IF NOT EMPTY(@subscriberkey) THEN
SET @rs= RetrieveSalesforceObjects("Contact", "Id, FirstName,LastName,Email", "Id", "=", @subscriberkey)
SET @rowCount = rowcount(@rs)
IF @rowCount > 0 THEN
SET @row = row(@rs,1)
SET @email = field(@row,"Email")
SET @firstname = field(@row,"FirstName")
%%[
VAR @subscriberkey, @email, @firstname, @lastname
SET @subscriberkey = _subscriberkey
IF NOT EMPTY(@subscriberkey) THEN
IF Substring(@subscriberkey, 1,3) == "00Q" THEN
/* Lead */
SET @rs= RetrieveSalesforceObjects("Lead", "Id, FirstName,LastName,Email", "Id", "=", @subscriberkey)
SET @rowCount = rowcount(@rs)
IF @rowCount > 0 THEN
SET @row = row(@rs,1)
<input type="text" name="FirstName"
data-field-type="Text" value="%%=v(@firstname)=%%">
%%[
var @apikey, @url, @response
set @apikey = Lookup("NASAapi","apikey","id","apod") // keep your apikey in a Data Extension
set @apikey = "7Apb3QN7qVsXPuPDcSZBKAPf8twca03C5w4Oxuyc" // or hardcode it into your CloudPage
set @url = concat('https://api.nasa.gov/planetary/apod?api_key=',@apikey)
set @response = HTTPGET(@url,false,0,@CallStatus)
]%%
%%[
var @apikey, @url, @response
set @apikey = Lookup("NASAapi","apikey","id","apod") // keep your apikey in a Data Extension
set @apikey = "7Apb3QN7qVsXPuPDcSZBKAPf8twca03C5w4Oxuyc" // or hardcode it into your CloudPage
set @url = concat('https://api.nasa.gov/planetary/apod?api_key=',@apikey)
set @response = HTTPGET(@url,false,0,@CallStatus)
]%%
@response: %%=v(@response)=%%
<script runat="server" language="javascript">
Platform.Load("Core","1");
//Get the @response variable from AMPscript
var response = Variable.GetValue("@response");
//Parse JSON
var json = Platform.Function.ParseJSON(response);
//Set the @hdurl variable to be accessible in AMPscript
<img style="height:100vh" src="%%=v(@hdurl)=%%">
%%[
var @apikey, @url, @response
set @apikey = Lookup("NASAapi","apikey","id","apod") // keep your apikey in a Data Extension
set @apikey = "7Apb3QN7qVsXPuPDcSZBKAPf8twca03C5w4Oxuyc" // or hardcode it into your CloudPage
set @url = concat('https://api.nasa.gov/planetary/apod?api_key=',@apikey)
set @response = HTTPGET(@url,false,0,@CallStatus)
]%%
<script runat="server" language="javascript">
Platform.Load("Core","1");