3

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>
1
  • I believe subscriberkey is unique to marketing cloud. When pulling from sales cloud, I think you have to use contactid May 8, 2018 at 20:53

1 Answer 1

8

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

%%[

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:

%%[

  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

1
  • 1
    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). May 9, 2018 at 11:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .