I have tried this many times and I have finally figured out how to use the smart capture form in a classic Editor - code view page. Below are the sequence of steps that I did.
- Build a cloud page using content builder and use the smart capture form and build whatever feature is required. Save and publish the form. Make sure it is working.
- If you go to code view tab on the cloud page in step1, you will get the master HTML code for the page. Copy that in a notepad.
- The Smart Capture block itself has its own HTML code for the block. click on the block and copy that code. In step 2, in your notepad code, you will see a div block with attribute data-type="slot" and data-key="col1". Replace this div block with the smart capture HTML code.
- Now the smart capture HTML block itself contains a div block with attribute data-type="slot". You need to replace this block with all the smart capture input elements code. When you click on the smart capture form in step 1 and then click on the input element, you will get the HTML code for the element. Copy that code for each element and replace the div block in your notepad
- Open the published cloud page URL in step 1 in a browser. Get the HTML code from the browser. Compare this HTML code with the HTML code you have in the notepad. You will see some javascript code is missing and the closing form tab missing. Copy all the missing code to your notepad version.
- Now you should have the final version of the HTML code in your notepad with all the smart capture code. Create a cloud page using classic editor, code view option and copy the entire HTML code from your notepad. Save and publish and this should work.
I understand this is a lot of work but once you do it, it will become very easy.
I have done this and it's perfectly working for me. Good luck!
In your email URL, you will need to assigning the parameter called 'email' and then apply the value like so :
URL/?asoc=CRM&email=%%email%%
However, I'm not 100% certain a SmartCapture form will be able to execute AMPScript in a text block. Personally I don't use SmartCapture and would typically build a custom cloud page, in which case the RequestParameter() function would work as you document - but you need to add email=
as a parameter tag to your URL
%%[ var @email set @email = RequestParameter("email") ]%%
Some words of advice / best practice however - in your solution, you intend to pass a raw/visible email address in the URL. This isn't a recommended practice as it's publicly visible. Also labelling the parameter 'email' wouldn't be advisable as it's clear what the expected value will be.
Ideally you should encrypt your email address (or any PII data), then apply it to the URL. On the Cloud Page you would then decrypt it etc. The reason for being security conscious is for example, if a customer clicked on a link at an Internet Cafe, their PII data is easily visible in Proxies etc.
Another (easier) alternative would be to use the CloudPagesURL()
function, which you can then pass the values securely/encrypted to the could page and then retrieve the values using the RequestParameter()
function
View the CloudPagesURL() technical here
Best Answer
I don't think this is possible as Smart Capture forms seem to be "insert" only.
This leads to the behavior that the form in your case does not submit due to a primary Key Violation (inserting the same key twice is not allowed).
A workaround to keep the drag-and-drop functionality can be to remove all Primary Keys from the data extension behind the form. Basically, keep this data extension as "dumb" as possible in terms of validation to accept all kinds of user input.
For each record inserted, populate a date field ("timestamp") with a default value of "now" (getdate() ) to discern the latest entry and use backend processing via e.g. SQL to create a "clean" data extension without duplicates, by e.g. keeping the newest entry.
Then use the cleaned up DE for any further processes.
To address your followup questions:
Can SSJS/AMPscript be used to display a message on the page that a record already exists and has been updated?
Yes.
Send the user to the page using CloudpagesUrl AMPScript function: This establishes the "user context" on the cloudpage, meaning that the personalization string %%_subscriberkey%% will resolve to the user's subscriber key. From this you can basically get all the user's data.
AMPscript can be used to perform a Lookup into your Data extension and check if there is an existing record with e.g. the same subscriber Key or email. However, we are of course leaving point-and-click territory here ;)
Can the cleaned up de be used as the entry event into a journey?
Yes.
That is pretty much the idea. accept all data into a validation-less data extension. Validate in the backend and clean up your data. use the cleaned up DE as source for a Journey that e.g. sends validated Leads and Contacts to Salesforce.
Create the SQL query that performs the cleanup and save it in an automation.
Next, build your journey. Set the Journey to Entry source: Data extension. Select your cleaned up DE as that Data Extension.
Next, set as Entry Source Schedule: "Automation" Select your Automation built earlier. Finish building the Journey as you wish.
Once you activate your Journey, navigate to the automation referenced. You will see the activation placed a "diamond" style icon behind the last step of the automation, which represents the injection of its result into the Journey.