0

I'm trying to create a technical and completely empty landing page in Cloud Pages that's going to be used for passing values to a Data Extension and then redirecting the person to website. I'm new to AmpScript but to achieve this result I prepared the followin:

  • Link redirecting to the Cloud Pages LP in the email
<a href="%%=redirectto(CloudPagesURL(123))=%%"
  • Code in the above-mentioned Cloud Pages LP that is supposed to insert data to the ButtonClicked column of DE (Test_DE) and after that redirect the person to the website.
%%[

var @buttonClicked
set @buttonClicked = "true"

set @insert = insertData("Test_DE","ButtonClicked", @buttonClicked)

%%=Redirect('https://google.com/')=%%

]%%

This code doesn't work and I'm pretty sure that the problem is with the insertData function as the Redirect worked fine when tested alone. Could you please point me in the right direction? What I'm doing wrong?

2
  • Where is the primary key being passed in? If the record already exists, then insertdata will fail as it is trying to insert an already existing record (unless you do not have a pkey assigned in your DE). Might try something like: insertdata("Test_DE", "EmailAddress",emailaddr,"ButtonClicked",@buttonClicked) just replace "EmailAddress" with your uniqueID. – Gortonington Aug 14 '20 at 16:45
  • I think you're right and the problem may lie within the fact that I'm not passing the primary key value but actually I already have a primary key for the person (email is sent to the DE that already has primary key filled). Is it possible to grab that primary key and then use it in the insertData function? – jamietaylor Aug 14 '20 at 19:22
0

Your InsertData is correct. However, you are mixing Ampscript block with inline Ampscript in your redirect function. You should use this instead:

%%[

var @buttonClicked
set @buttonClicked = "true"

set @insert = insertData("Test_DE","ButtonClicked", @buttonClicked)

If (@insert > 0) then
Redirect('https://google.com/')
Else
Outputline(“Something went wrong”)
Endif 

]%%
1
  • I used the code above but I still get an error when I'm clicking the button in the email redirecting to the Cloud Pages LP saying: 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. The Cloud Pages LP is already published – jamietaylor Aug 14 '20 at 16:09

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.