2

So I've been through this question and the answers, but am still having some trouble building a CloudPage that retrieves SubscriberKey from the URL. It works if I hardcode a Salesforce record ID as "@Id":

%%[
var @Id, @firstName, @lastName, @email, @subscriberRows, @subscriberRow, @OptIn, @OptOut
set @Id = "0030O00002GHNIvQAP"

IF RequestParameter("submitted") != true THEN

set @subscriberRows = RetrieveSalesforceObjects(
 "Contact",
 "FirstName,LastName,Email,HasOptedInToEmail__c,HasOptedOutOfEmail",
 "Id", "=", @Id )
]%%

but if I try to "retrieve" the subscriberkey as described elsewhere

%%[
var @Id, @firstName, @lastName, @email, @subscriberRows, @subscriberRow, @OptIn, @OptOut
set @Id = RequestParameter("Subscriberkey")

IF RequestParameter("submitted") != true THEN

set @subscriberRows = RetrieveSalesforceObjects(
 "Contact",
 "FirstName,LastName,Email,HasOptedInToEmail__c,HasOptedOutOfEmail",
 "Id", "=", @Id )
]%%

The page doesn't preview and if I go ahead and publish it I get an Internal Server Error when I go to the URL. The page is a CloudPage Landing Page, and I have created a link in an email using the Cloud Page - Landing Page link function. the HTML produced in the email looks like this:

<a alias="" conversion="false" data-linkto="cloudpageslandingpage" href="%%=CloudPagesURL(176)=%%" style="color:#808080;text-decoration:none;" title="">Simplified page</a>
  • I believe subscriberkey is unique to marketing cloud. When pulling from sales cloud, I think you have to use contactid – Tom Callahan May 8 '18 at 20:53
3

If you're arriving at a CloudPage from a CloudPagesURL() link in an email, then you can retrieve the _subscriberKey personalization string with AttributeValue():

%%[
var @Id, @firstName, @lastName, @email, @subscriberRows, @subscriberRow, @OptIn, @OptOut
set @Id = AttributeValue("_subscriberkey")

IF RequestParameter("submitted") != true THEN

set @subscriberRows = RetrieveSalesforceObjects(
 "Contact",
 "FirstName,LastName,Email,HasOptedInToEmail__c,HasOptedOutOfEmail",
 "Id", "=", @Id )
]%%

Here's an example that I keep as a reminder:

%%[

var @p1, @p2, @p3

set @p1 = AttributeValue("PersonalizationStringName")
set @p2 = RequestParameter("FormPostVariableName")
set @p2 = QueryParameter("URLParameterName")

]%%
@p1: %%=v(@p1)=%%
<br>@p2: %%=v(@p2)=%%
<br>@p3: %%=v(@p3)=%%

20180509 Edit: clarification per @Eliot's comment

  • Yes, this will work, as long as you are using the CloudPagesURL function as the link in your email (or if you select the CloudPage from the Content Builder interface, which builds the CloudPagesURL function for you). – Eliot Harper May 9 '18 at 11:25

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.