I'm trying to pre-populate the hidden fields on my Smart Capture form from a CloudPage URL to gather survey responses. Here's what I've done so far:
I have an email I want to send to data extension "Test Extension". Extension has these fields:
- Contact ID (primary key, relates to subscribers on subscriber key)
- First Name
- Last Name
I want to use the Smart Capture form to transfer this data over to extension "Survey Results" and fill out two extra fields there, Rating and Comments.
My email contains a link to a CloudPage URL (Page ID 123) that should pass subscriber info through an encrypted query string to pre-populate hidden attributes on my Smart Capture form. Here is what I have to generate that URL:
<a href="%%=RedirectTo(CloudPagesURL(123, 'Contact ID', @contactid, 'First Name', @firstname, 'Last Name', @lastname, 'Email', @emailaddr))=%%">
Next, I placed this AMPscript in an HTML block at the top of my email:
%%[
Set @contactid = [Contact ID]
Set @firstname = [First Name]
Set @lastname = [Last Name]
Set @emailaddr = Email
var @firstname, @lastname, @emailaddr
set @firstname = Lookup("Test Extension", "First Name", "Contact ID", @contactid)
set @lastname = Lookup("Test Extension", "Last Name", "Contact ID", @contactid)
set @emailaddr = Lookup("Test Extension", "Email", "Contact ID", @contactid)
set @contactid = Lookup("Test Extension", "Contact ID", "Contact ID", @contactid)
]%%
Lastly, I set the value of the hidden attributes in my Smart Capture form on my CloudPage like this example:
%%[SET@contactid=QueryParameter('Contact ID')]%%
I sent the email to myself as a contact in Test Extension and clicked the link. The link goes to my page with the Smart Capture form, and I submitted the form with success. But when I go to the target data extension "Survey Responses," a record has been created with values only in the two visible fields I filled out (Rating and Comments). There's nothing in Email or First or Last Name, and the Contact ID has value of 0. Can you tell where I'm going wrong?