Cloud Pages
Creating a Lead/Contact Capture Page
Why submit a cloud page to Salesforce?
If you create new contacts in SFMC you end up with duplicates when they are synced to Salesforce. To avoid this issue keep all of your marketing leads & contacts in Salesforce and sync them to SFMC from there. This cloud page form is designed for Contacts, but could be easily modified for Leads. This form also assumes you know the user that you want to assign leads to, if you don't or if you need to assign them to a queue, you will need to modify how this form works.
Step 1: Retriever the Contact/Lead Owner's Data
Create the retrieval ampscript you will need to correctly assign the contact to a user:
If your lookup value is a query parameter:
<!-- %%[ var @stepRetrieve SET @sfAgentUserId = RequestParameter('sfUserId') set @AccountId = RequestParameter('AccountId') SET @submitted = RequestParameter('submitted') ]%% -->Lookup the user ID if needed
<!--%%[SET @sfAgentUserRows = RetrieveSalesforceObjects('User','ContactId','Id','=',@sfAgentUserId) SET @sfAgentUserRowCount = RowCount(@sfAgentUserRows)
IF @sfAgentUserRowCount > 0 THEN SET @sfAgentUserRow = Row(@sfAgentUserRows,1) SET @sfAgentContactId = Field(@sfAgentUserRow, 'ContactId') SET @stepRetrieve = 'User ID' ELSE SET @sfAgentContactId = @sfAgentUserIdSET @stepRetrieve = 'Contact ID' ENDIF]%%-->
Step 1.5
You can populate the Cloud Page with their Rep's (Record Owner's) information using RetrieveSalesforceObjects Ampscript.
Step 2: Create the form
The form code can be download there. This form uses the following SF Ampscript to query/create records:
SET @subscriberRows = RetrieveSalesforceObjects("Contact","Id,FirstName,LastName,Email,AccountId,OwnerId","Email", "=", @email,"OwnerId","=",@sfAgentUserId)AND
SET @UpdateContact = UpdateSingleSalesforceObject( 'Contact',@ContactID, "FirstName", @firstname, "LastName", @lastname, "Email", @Email, "MobilePhone",@mobile, "OwnerId",@sfAgentUserId, "AccountId",@sfAgentAccountId, "LeadSource","Open House", "RecordTypeId", @RecordTypeId,"Pre_Approved_Amount__c",@preapprovedamount,"Pre_approved__c",@preapproved,"Pre_Qualified__c",@prequalified,"HasOptedOutOfEmail",@mobileoptout,"Email_Opt_Out_DateTime__c",@now,"Email_Opt_Out_Source__c","Source Info")Step 4: Styling the form
input[type="radio"] { width: auto; }input[type="submit"] { max-width: 280px; padding: 10px 20px; }textarea { width: 90%; height: 90px; }.switch-field label:hover { cursor: pointer !important; }.switch-field input:checked + label { background-color: #552448; color: #FFFFFF; box-shadow: none; }.switch-field label:first-of-type { border-radius: 4px 0px 0px 4px; border-width: 2px; color: #552448; font-weight: bold; }.switch-field label:last-of-type { border-radius: 0px 4px 4px 0px; }To be continued...