SalesforceSalesforce Marketing Cloud SpecialistMarketing Cloud DeveloperEasy
How do SET and VAR work in AMPscript, and when must you declare with VAR?
Suggested answer
VAR @name explicitly declares a variable, which is optional in most contexts — AMPscript will auto-declare on first SET. However, explicit VAR is recommended for clarity and is required in some strict server-side contexts (CloudPages with strict parsing). SET @name = expression assigns a value. Variables are page-scoped; they do not persist across send-time personalisation calls on different emails. Example: %%[ VAR @fname SET @fname = AttributeValue("FirstName") ]%% then output with Hello %%=@fname=%%.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.