I just started using content builder and noticed it isn't clear how to define an AmpScript block as part of a template. I tried using but that seems to break the template formatting. Are ampscript blocks supported?
3 Answers
AMPScript is definitely supported in Content Builder. AMPScript typically does jack up the code in the editor.
Here's a little trick I use to "pretty up" the AMPScript:
%%[/* Modify to view AMPScript <div style="display:none"> */
/* your big blob of AMPScript goes here */
/* </div> */
]%%
Update: Placeholders vs Content Areas
Content area placeholders for Paste HTML templates <custom type="content" name="test">
are different than AMPScript blocks. When you define a template, you can add as many placeholders as you want. You can then edit the content of those placeholder content areas when you create a new templated email.
AMPScript blocks begin and end with %%[
and ]%%
. You can add AMPScript blocks directly in the template HTML or you can add them to the placeholder content area once you create the email based on the template.
-
1I also have found using the full script tag: script runat=server language=ampscript your ampscript here /script works too to hide it from displaying - but recently there have been a few times that this now displays when put inside the body tag and I am not sure what has changed in their UI that makes this happen. Oct 4, 2016 at 12:37
-
So in the email studio, you would create a template and then add <custom type="content" name="AMPscript"> just below the <body> section to define the AmpScript block. I tried the same thing in Content Builder but it doesn't create a content block for editing in the template? Is there a new way to do this? Oct 4, 2016 at 23:28
-
I updated my answer above to make a distinction between placeholders and AMPScript blocks. Oct 5, 2016 at 14:47
-
Hi Adam...I just tried this and found that when I put the div container within the block, it hid everything in the block and left the %% []%%. To get it to work I had to put the div container outside the bracket May 15, 2017 at 16:46
Breakdown of each element in the Content Area definition:
- data-type: must always be "slot"
- data-key: unique identifier for the content area. Must be unique within each template.
- data-max-blocks: the maximum number of blocks allowed in that content area. If not defined, it's unlimited.
- data-allowed-blocks: the types of blocks that can be dragged to that content area. If not defined, all types are allowed in that content area.
- data-label: the message that appears inside the content area if it's empty. Default is "Drop blocks or content here" if not defined.
The placeholder for Content Builder is different than for Classic Content, it's basically div element with custom attributes. Looks like this:
<div data-type="slot" data-key="uniqName" data-max-blocks="" data-allowed-blocks="" data-label="Drop content blocks here"></div>
I can't find reference in documentation what each attribute is for.