0

In our email we have multiple content blocks and I am trying to call the content block within a cloud page using a simple AMPscript code something like below

  <!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
    <title>test</title>
</head>
<body>

 %%= TreatAsContent(ContentBlockByKey("CONTENT_BLOCK_KEY")) =%%

  </body>
</html>

But I get an error page with status code 500

Could anyone tell me how to call a content block using AMPscript in a CloudPage? or any other way to resolve this easily?

4
  • Remove the spaces and try %%=TreatAsContent(ContentBlockByKey("CONTENT_BLOCK_KEY"))=%% Apr 19, 2022 at 11:26
  • That worked, thank you so much..
    – vorak
    Apr 19, 2022 at 11:33
  • what is the issue with spaces in cloudpage? But same code with spaces works in email
    – vorak
    Apr 19, 2022 at 11:36
  • 1
    @JonasLamberty : You should add that as an answer (which hopefully the OP will select). That would be much better for future seekers/readers.
    – Moonpie
    Apr 19, 2022 at 11:52

1 Answer 1

1

Remove the spaces and try

%%=TreatAsContent(ContentBlockByKey("CONTENT_BLOCK_KEY"))=%%

As to why your code works in emails, good question. I've never tried this pattern with spaces, but they are definitely superfluous at best.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .