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).