---
schema_version: "1"
id: 72e54a61ed1fa910c7e1e2b92fcf4d789c316bdb68f4fd6617ca470dbf324192
title: Adding AMPscript to Your Content
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/guide/language-basics/mc-ampscript-guide-language-basics-adding-to-content.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/guide/mc-ampscript-guide-language-basics-adding-to-content.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: c5a85121d978ad0a3f1a94b4ca67e31450f442047ec2a7d2e8d9dbe347dc5e45
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# Adding AMPscript to Your Content

There are three ways to add AMPscript code to your content: by using inline code, by adding code blocks, or by using tag-based scripting. The first two of these methods use special delimiters to denote the beginning and ending of the code that you want Marketing Cloud Engagement to interpret. In the third method, you delineate the AMPscript code with `<script>` tags.

When you close an AMPscript block, use the same type of closing delimiter as you used to open the block. For example, if you open a block using tag-based scripting, you can't close it by using the closing code block delimiter.

## Inline AMPscript

Use the `%%=` and `=%%` delimiters to add AMPscript code inline with your content. Inline AMPscript is frequently used within HTML tags to dynamically populate the content of a message. In this basic example, a section of AMPscript is included inline within an HTML `<p>` tag.

```
<p>Hello %%= Lowercase(@name) =%%,</p>
```

You can only execute a single function in a section of inline AMPscript. However, you can nest functions within an inline function. This example uses the `Iif()` function to test a condition. In this case, the condition is whether the value of the variable `@var` is empty, which is determined by using the nested `Empty()` function.

```
%%= Iif(Empty(@var),'123','456') =%%
```

## AMPscript Code Blocks

You can also include multi-line blocks of AMPscript code in your messages. Use the `%%[` and `]%%` delimiters to begin and end a code block, respectively. With a code block, you can define multiple variables and execute multiple functions. Code blocks use the syntax shown in this example.

```
%%[
  Var @free_shipping, @country
  Set @country = Uppercase([CountryCode])
  If ( @country == "US" or @country == "CA" ) then
    Set @free_shipping = true
  Else
    Set @free_shipping = false
  EndIf
]%%
```

## AMPscript Tag-Based Syntax

Tag-based syntax for AMPscript standardizes the syntax used to declare AMPscript blocks with the syntax of Server-Side JavaScript (SSJS). This syntax makes it easier for developers to switch between AMPscript and SSJS.

This example shows the complete syntax required to declare an AMPscript block.

```xml
<script runat="server" language="ampscript">
  Var @free_shipping, @country
  Set @country = Uppercase([CountryCode])
  If ( @country == "US" or @country == "CA" ) then
    Set @free_shipping = true
  Else
    Set @free_shipping = false
  EndIf
</script>
```
