I have been asked to figure out how to direct submissions from multiple 3rd party forms into one Marketing Cloud data extension.
I have the following built but instead of returning one record with the proper form URL, it's returning 2 duplicate records with FormURL A, no matter what form I test.
I'm new to ampscript and can see why this is happening, but am unsure of what to change?
Note: Please ignore the referrer lines, that's also a test but doesn't seem to affect the post.
%%[
SET @FormURL = RequestParameter("FormURL")
SET @FirstName = RequestParameter('name')
SET @LastName = RequestParameter("LastName")
SET @Company = RequestParameter("Company")
SET @Email = RequestParameter("email")
SET @ampscriptReferrer = RequestParameter("referrer")
IF @FormURL == "Example:FormURL A" THEN
SET @MIG_Test_A= InsertDE('MIG_Test_A','FirstName',@FirstName,'LastName',@LastName,'Company',@Company,'EmailAddress',@Email,'FormURL',@FormURL,'preURL',@ampscriptReferrer)
ENDIF @FormURL == "Example:FormURL B" THEN
SET @MIG_Test_A= InsertDE('MIG_Test_A','FirstName',@FirstName,'LastName',@LastName,'Company',@Company,'EmailAddress',@Email,'FormURL',@FormURL,'preURL',@ampscriptReferrer)
ENDIF
]%%
I think you are mistakingly using ENDIF instead of ELSEIF. Please try this code instead:
%%[
SET @FormURL = RequestParameter("FormURL")
SET @FirstName = RequestParameter('name')
SET @LastName = RequestParameter("LastName")
SET @Company = RequestParameter("Company")
SET @Email = RequestParameter("email")
SET @ampscriptReferrer = RequestParameter("referrer")
IF @FormURL == "Example:FormURL A" THEN
SET @MIG_Test_A= InsertDE('MIG_Test_A','FirstName',@FirstName,'LastName',@LastName,'Company',@Company,'EmailAddress',@Email,'FormURL',@FormURL,'preURL',@ampscriptReferrer)
ELSEIF @FormURL == "Example:FormURL B" THEN
SET @MIG_Test_A= InsertDE('MIG_Test_A','FirstName',@FirstName,'LastName',@LastName,'Company',@Company,'EmailAddress',@Email,'FormURL',@FormURL,'preURL',@ampscriptReferrer)
ENDIF
]%%
When using ENDIF
, you close your IF
statement, meaning everything after will still be executed. When using ELSEIF
, you will only execute the code after ELSEIF
if it meets the condition. In your case: @FormURL == "Example:FormURL B" THEN