0

I have created a landing page in Marketing Cloud that interacts with my Salesforce Sales Cloud. This page is meant to be a custom landing page where users can opt out of specific email lists or unsubscribe completely. The code is suppose to take the Subscriber ID (which is always matched with a custom field Contact Casesafe Id (contact_casesafeid__c) and pull through their contact information in Salesforce. However, the first line SET @contactId = _subscriberkey does not pull through the Subscriber Key from the email with the embedded link to this page.

I've tested with changing out _subscriberkey to an existing Contact ID and it worked, but I have no idea how to get the Subscriber ID to be pulled through from the email sent. What could I be doing wrong?

I keep receiving the bottom error: "Sorry, something went wrong (missing subscriber key).

     %%[
     SET @contactId = _subscriberkey

     IF NOT EMPTY(@contactId) THEN

     /* fetch data from Sales Cloud to show in the form */

     SET @subscriberRows = RetrieveSalesforceObjects(
     "Contact",





 "Id,FirstName,LastName,Email,Inside_the_Ropes__c,Wellness_Check_In__c,Special_Promos__c,HasOptedOutOfEmail",
        "Id", "=", @contactId
        )

       IF RowCount(@subscriberRows) > 0 THEN

       SET @row = row(@subscriberRows,1)
       SET @FirstName = field(@row,"FirstName")
       SET @LastName = field(@row,"LastName")
       SET @Email = field(@row,"Email")
       SET @InsideTheRopes = field(@row,"Inside_the_Ropes__c")
       SET @WellnessCheckIn = field(@row,"Wellness_Check_In__c")
       SET @SpecialPromos = field(@row,"Special_Promos__c")
       SET @HasOptedOutOfEmail = field(@row,"HasOptedOutOfEmail")

       IF @InsideTheRopes == true THEN SET @InsideTheRopeschk = "checked" ENDIF
       IF @WellnessCheckIn == true THEN SET @WellnessCheckInchk = "checked" ENDIF
       IF @SpecialPromos == true THEN SET @SpecialPromoschk = "checked" ENDIF

     ELSE
     ]%%

     Sorry, something went wrong (no records found).

     %%[
     ENDIF

     ELSE
     ]%%

     Sorry, something went wrong (missing subscriber key).

1
  • 1
    IF you mean that the subscriber info is not passed from email to landing page. You likely need to utilize the CloudPagesURL() function to pass this info across. (developer.salesforce.com/docs/…) This will pass all the data from the sendable data source to the page. Your above should then function as you expected. May 1, 2020 at 19:23

2 Answers 2

0

You would need to close the IF statement with ENDIF in the code which you have shared.

Since you are saying that it is working properly by changing out _subscriberkey, I assume you missed it in the code but not in cloud page.

You are getting the error "Sorry, something went wrong (missing subscriber key)" because I believe you are calling/loading cloud page directly.

Instead try to add a button in an email and link custom preference centre cloud page in an email and preview or send it to the respective contact ID then click on the button in email. Then it should work.

Let me know if this helps.

0

It turned out I needed to change out

SET @contactId = _subscriberkey

to be

SET @contactId = requestparameter('Subkey')

so that in my email coding, I could use

<a href="%%=RedirectTo(CloudPagesURL([cloudpage id], 'SubKey', _subscriberkey))=%%">Here's my subscription center.</a>

I hope this helps someone else!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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