Quantcast
Channel: Active questions tagged ampscript - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 594

Pass values using SSJS and AMPscript on email

$
0
0

Firstly, I apologise - I am a beginner with JavaScript and SSJS. I am trying to send an email with a CTA button that has an url to an external page, which will prepopulate values from a DE on the form.

This is the html I have, I don't get any errors on the email but the values does not pass through. I am using the %%=v(@url)=%% as link url. Thank you in advance!

    %%[SET @FirstName = FirstNameSET @LastName = LastNameSET @Email = EmailSET @MailingPostalCode = MailingPostalCodeSET @cID = IdSET @Title = SalutationSET @Mob = MobilePhone]%%<script runat="server" language="JavaScript" executioncontexttype="Post" executioncontextname="test">Platform.Load("core","1.1.5");       function getRandomString(leng)       {         var str = "";                     for(var i = 0; i < leng; i++)         {           str += parseInt(Math.random() *9);                     }         return str;       }       var version = "";       var ttl = Variable.GetValue("@Title");       var ph = Variable.GetValue("@Mob");       var sfid = Variable.GetValue("@cId");       if(ttl)       {        version = "2";       }       if(ph)       {        version = "3";       }       var fn = Variable.GetValue("@FirstName");       var s = Variable.GetValue("@LastName");       var e = Variable.GetValue("@Email");       var p = Variable.GetValue("@MailingPostalCode");       var mystring = "fn="+ fn +"&s="+ s +"&e="+ e +"&p="+ p;       //if(version == "2")       //{       //   mystring = "ttl="+ttl+"&fn="+ fn +"&s="+ s +"&e="+ e +"&p="+ p;       //}       //if(version == "3")       //{          mystring = "ttl="+ttl+"&fn="+ fn +"&s="+ s +"&e="+ e +"&p="+"3058"+"&ph="+ ph +"&sid="+ sfid;       //}       var encString = getRandomString(3);//random 3 at start       var sep = "";       for(j = 0; j < mystring.length; j++) {         encString = encString + sep + getRandomString(1) + mystring.charCodeAt(j) + getRandomString(1);         sep = "-";       }       encString = encString + getRandomString(3); //random 3 at end       var url = encString+"&v="+version+"&utm_medium=email&utm_source=company&utm_campaign=brand|generic|comp-mpe&utm_content=brand-edm&utm_term=loyalty|own"       Variable.SetValue("@url", url);    </div></div></script>

Viewing all articles
Browse latest Browse all 594

Latest Images

Trending Articles



Latest Images