[SalesForce] Sending and Retrieving AmpScript Values in Email strings for Microsites

We're using personalization strings in the url for the Unsubscribe links in our emails. The url links to our Preference Center microsite and includes certain values such as Job ID, List ID, MemberID, etc. We also want to add the Subscriber Key to the string but I'm not quite understanding the necessary syntax because I seem to be able to get a value for it.

Here's an example of the string are are using: https://our.microsite.com/preference/?emailaddress=%%emailaddr%%&s=%%ex2;subscriberid%%&j=%%ex2;jobid%%&mid=%%ex2;MemberID%%&l=%%ex2;listid%%&jb=%%ex2;_JobSubscriberBatchID%%&ju=%%ex2;joburlid%%&sk=%%_subscriberkey%%

Here is the code for creating the variables from the :

Set @emailAddress = [emailaddr]

Set @subKey = [_subscriberkey]
Set @jobID = [JobID]
Set @listID = [ListID]
Set @batchID = [_JobSubscriberBatchID]
Set @subscriberID = [subscriberid]
Set @accountMID = [MemberID]

After creating variables for the strings I get the following values:

@subKey = , @accountMID = ##########, @emailAddress = mySampleEmailAddress@gmail.com

Any ideas on why there's no value for the subscriber key? Is it the syntax in the the personalization string?

Best Answer

Use the CloudPagesURL function in an email to pass information via a URL in an encrypted query string:

e.g.

<a href="%%=RedirectTo(CloudPagesURL('pageID','parameter1','value1','parameter2', value2))=%%">

The above will pass along 'parameter1' & 'parameter2' (just examples and more parameters can be passed along too) but also default send string values also get passed through the link query too. A list can be found here: https://help.salesforce.com/articleView?id=mc_es_available_personalization_strings.htm&type=5

As you'll see subscriber Key is one of them: %%_subscriberkey%%

So in your microsite code, you can assign the subscriber key to a variable, without having to directly pick it up using the QueryParameter() Ampscript function.

e.g.

set @subId = AttributeValue("_subscriberkey")