I have a doubt with regards to Code Snippet VS AMPScript. To give bit of a context:

I have a campaign to run biweekly with a new discount code. Until now, every week i was going and manually making edits to every email content and more. I realised as i have all information of what the discounts are going to be in the future, i could create a code snippet and populate information via using flag in my query to get users the right content. And i used this code snippet by contentblockid in my ampscript and i marked the variables as ",@content_discount," but it was not populating the fields rightly.

<attached image - code_snippet_v1 + subject_line_v1 + amp_script_v1> amp_Script_v1 code_snippet_v1subject_line_v1email_v1email2_v1

Set @subHeadlineTop = concat("Get ",@content_discount," off") Set @subHeadlineTop = concat("Get", ",@content_discount,", "off") But it did not work until. The same thing in subject line worked fine, but in the content part body/header it did not render.

Only when i used %%v=(@content_discount)=%% it populated the content. Set @subHeadlineTop = Concat("Get %%=v(@content_discount)=%%" , " off")

<attached image - code_snippet_v2 + amp_script_v2> [![code_snippet_v2subject_line_V2content_v2

Could someone explain why?

The 2nd way i went about was defined attributes/variables and set all the content in the code snippet and pulled it to the email. And in the code snippet i used like this ",@content_discount," and it worked like magic.

Is there a difference of using these two that i am not aware off? I am a newbie to this, and any kind of clarity here would be of great help.

1 Answer 1


I'm pretty sure the initial code (the first snippet in the screenshot) would've worked if the outer quote marks were changed from single to double. The concat for @subHeadlineTop...

concat('<br><b>Get ",@content_discount," off</b>')

...might look like three separate pieces are being joined together when skimming over the code, but if you notice the outer single quotes, the argument actually ends up being a single string. This is why you see the literal/unprocessed string ",@content_discount,". Compare this to the concat for @subjectLine which correctly uses matching quote marks.

You must log in to answer this question.

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