0

I have a use case as below,

I'm sending an email from the email studio when the audience clicks on the email CTA button, it takes them to a cloud landing page then I want to send a user's value to data extension when the users click the CTA button on the landing page.

I have the below code in the email and passing URL parameters values when email CTA button clicked: %%=RedirectTo(CloudPagesURL(1234))=%%

and I have placed the below code in the LP in order to work when the audience clicks the CTA button:

<div class="cta-wrapper">

%%[ var @Subkey, @source, @medium, @campaignname
SET @Subkey = RequestParameter('sfmc_id')
SET @source = RequestParameter('utm_source')
SET @medium = RequestParameter('utm_medium')
SET @campaignname = RequestParameter('utm_campaign')

SET @value = upsertData("Test_LP1",1,"sfmc_id",@Subkey,"utm_source",@source,"utm_medium",@medium,"utm_campaign",@campaignname,"Date",NOW())
]%%

<'button class="cta-button cta-button_primary" onclick="window.open('https://abc','_blank')">Click here!</button>
<a href="#loyalty-programs">Want to know more?</a>
</div'>

the above ampscript works as it updates the data extension with value when the audience opens the LP but instead when the audience clicks the CTA button in the LP.

Does anyone have an idea how this can be fixed? I want to send value to data extension when the audience clicks the CTA button on the LP instead when they open it.

Thanks and Best regards, Vinoth

0

I tried to detail the processing you require here:

enter image description here

However, in the current setup you describe, you have only the "Form" page built, and once it loads, it directly talks to your database, which is entirely expected, and obviously too early.

This whole thing could technically be done without the second page, but let's start simple:

You have to understand that your current page, even if it has only one button, is a webform regardless. You want the input of that form processed, and therefore it has to be submitted to a handler.

In the scenario easiest to explain, build a second Cloudpage, the "Handler" on the picture. This page's URL will be the target of your CTA button. Your button should be an HTML element of type "submit", and your form will possibly have to send the parameters you have pulled via "RequestParameter" along as additional inputs of type "hidden".

Read up on simple form structures and the input element here: https://www.w3schools.com/tags/tag_input.asp &&

https://w3schools.com/html/html_forms.asp , including this example: https://w3schools.com/html/tryit.asp?filename=tryhtml_form_submit_id

Make sure you include method="post" in your form.

This will send the parameters in a POST request to the handler. Remove the Upsertdata functionality from the form, and place it on the handler. That way, it will execute after the button is clicked and the users reaches the handler. If you don't want the user to end up on this page, follow the Upsertdata call with an AMPScript "Redirect()" function and send the user elsewhere.

Hope this helps, and I didn't explain it in a manner too basic or complicated.

8
  • Thanks for the detailed information. When I create a second cloud page (handler form), will this page be visible to the customers when they click on the cloud LP CTA button? and How can I input the customer as submitted when they click on the cloud LP CTA button which takes them to an externally hosted webpage. – Vinoth Kumar Jul 17 '20 at 11:21
  • The handler page will be "visible" for a split second if it contains a Redirect() elsewhere. It is the same like any click from an email, which technically is a redirect and nobody really notices a difference. This is also the answer how you deal with an external webpage. Your handler is called, your handler does the processing and the user is instantly redirected. The external page then does nothing but display and you don't need to change anything there. – Jonas Lamberty Jul 17 '20 at 11:47
  • Would you be able to help with sample code that I can follow? <button class="cta-button cta-button_primary" <form action='abc.com','_blank'> <input type="submit" value="Submit"> </button> This doesn't seem to be help for me. – Vinoth Kumar Jul 17 '20 at 12:08
  • Read this resource. w3schools.com/html/html_forms.asp including this example: w3schools.com/html/tryit.asp?filename=tryhtml_form_submit_id ; Make sure you include method="post" in your form. – Jonas Lamberty Jul 17 '20 at 13:08
  • I have created a 2nd form handler and placed the amps but I get the 500 error page. I'm sharing the code, can you suggest, please? <form action="/action_page.php" target="_blank" method="post"> <input id="submitted" type="hidden" name="submitted" value="submitted" /> <input type="submit" value="Submit"> %%[ if atSubmitted == "Submitted" THEN SET atvalue = upsertData("Test_LP1",1,"sfmc_id",atSubkey,"utm_source","Date",NOW()) ENDIF ]%% %%[ if atSubmitted == "Submitted" THEN %%=RedirectTo(atLink)=%% ENDIF ]%% </form> at=@ – Vinoth Kumar Jul 21 '20 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.