I am really new to SSJS but what I am trying to achieve is to pass some parameters in the URL from an email and capture them in the cloud page and then save that data into a DE using SSJS.
At the moment I have written the following:
%%[var @SubscriberKey,@email,@date
SET @SubscriberKey=RequestParameter('SubscriberKey')
SET @email=RequestParameter('email')
SET @date = NOW()]%%
<script runat="server">
Platform.Load("Core", "1.1.1");
var request = {}
var SubscriberKey = Variable.GetValue("@SubscriberKey");
var email = Variable.GetValue("@email");
var date = Variable.GetValue("@date");
Write(SubscriberKey);
Write(email);
Write(date);
var SSJSentries = DataExtension.Init("SSJS entries");
var row = {};
row.EmailAddress = request.email;
row.SubscriberKey = request.SubscriberKey;
row.date = request.date;
{
Write("<br><br>DE row: " + Stringify(row));
}
try {
// attempt to add a row
SetVar("rowAddResults", SSJSentries.Rows.Add(row));
}
catch (e) {
Write("<br>Exception: " + e);
}
</script>
When I redirect to the cloud page from the email I get the following message:
My Subscriber Key Value [email protected] 9/26/2019 5:04:50 AM
DE row: {"EmailAddress":null,"SubscriberKey":null,"date":null}
Exception: Object expected: SetVar
I can pass the params OK after the GetVariable but I don't know how to write to request the values & insert them in the Data Extension.
What did I miss?
Giulietta