---
schema_version: "1"
id: 36c56a623ca5361cabfbb045e676c986c13261e9cfd146d259dbd993aabe4435
title: BarCodeUrl()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/ampscript/references/content/mc-ampscript-reference-content-barcode-url.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-content/mc-ampscript-reference-content-barcode-url.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: afe07c4a2cf059bc16eb4963072950f82477b3b3e07c0f44f46ad756601c082c
products:
  - AMPscript for Marketing Cloud
  - Marketing Cloud
---
# BarCodeUrl()

Generates a barcode based on an input string. Most of the barcode types that the function can generate are linear (one-dimensional), although it can generate two-dimensional Data Matrix and PDF417 codes. The function can’t be used to create QR codes.

You can call this function up to two times per message or landing page.

## Availability

<table>
  <tr>
    <td>Marketing Cloud Engagement</td>
    <td>✅ Yes</td>
  </tr>
  <tr>
    <td>Marketing Cloud Next</td>
    <td>❌ No</td>
  </tr>
</table>

## Syntax

```
BarCodeURL(valueToConvert, barcodeType,
           width, height, checksumValue,
           boolShowText, altText,
           rotation, boolTransparentBG)
```

The `BarCodeURL()` function has nine parameters:

- `valueToConvert` (string): Required. The value that you want to convert into a barcode.
- `barcodeType` (string): Required. The type of barcode to create. See [Supported Barcode Types](#supported-barcode-types) for a list of possible values.
- `width` (number): Required. The width of the barcode in pixels.
- `height` (number): Required. The height of the barcode in pixels.
- `checksumValue` (string): A checksum value for the barcode.
- `boolShowText` (boolean): If `true` or `1`, the function includes the text of `valueToConvert` under the barcode.
- `altText` (string): Alternate text to display under the barcode. The function only adds the specified text to the barcode when the value of `boolShowText` is `false`.
- `rotation` (number): Orientation of the barcode in degrees. Accepted values: `0`, `90`, `180`, `270`.
- `boolTransparentBG` (boolean): If `true` or `1`, the barcode includes a transparent background. Otherwise, the background is white.

## Supported Barcode Types

The `BarCodeUrl()` function supports a variety barcode encoding standards. This table describes the features and limitations of each supported barcode type.

| Code          | Name                | Type            | Character Limit | Allowed Characters                                                                  | Notes                                     |
| ------------- | ------------------- | --------------- | --------------- | ----------------------------------------------------------------------------------- | ----------------------------------------- |
| `codabar`     | Codabar             | Linear          | Variable        | Uppercase letters A–D, numbers 0–9, and these characters: `-$:/.+`                  | Must begin and end with a letter A–D      |
| `code11`      | Code 11             | Linear          | Variable        | Numbers 0–9 and `-`                                                                 |                                           |
| `code128auto` | Code 128 Auto       | Linear          | Variable        | All ASCII characters                                                                |                                           |
| `code128a`    | Code 128 A          | Linear          | Variable        | Uppercase ASCII characters, numbers 0–9, and ASCII special characters               |                                           |
| `code128b`    | Code 128 B          | Linear          | Variable        | Uppercase and lowercase ASCII characters, numbers 0–9, and ASCII special characters |                                           |
| `code128c`    | Code 128 C          | Linear          | Variable        | Numbers 0–9                                                                         |                                           |
| `code39`      | Code 39             | Linear          | Variable        | Uppercase letters (A–Z), numbers (0-9), spaces, and these characters: `-.$/+%`      |                                           |
| `code39ext`   | Code 39 Extended    | Linear          | Variable        | Any character in the extended ASCII character set                                   |                                           |
| `code93`      | Code 93             | Linear          | Variable        | Uppercase letters (A–Z), numbers (0-9), spaces, and these characters: `-.$/+%`      |                                           |
| `code93ext`   | Code 93 Extended    | Linear          | Variable        | All ASCII characters                                                                |                                           |
| `datamatrix`  | Data Matrix         | Two-dimensional | 1556 bytes      | All extended ASCII characters                                                       | Binary encodings aren’t supported         |
| `ean13`       | EAN 13              | Linear          | 13 digits       | Numbers 0–9                                                                         |                                           |
| `ean8`        | EAN 8               | Linear          | 8 digits        | Numbers 0–9                                                                         |                                           |
| `industr25`   | Code 25 Industrial  | Linear          | Variable        | Numbers 0–9                                                                         |                                           |
| `interl25`    | Code 25 Interleaved | Linear          | Variable        | Numbers 0–9                                                                         |                                           |
| `msi`         | MSI Plessey         | Linear          | Variable        | Numbers 0–9                                                                         |                                           |
| `pdf417`      | PDF 417             | Two-dimensional | 1108 bytes      | All extended ASCII characters                                                       | Binary encodings aren’t supported         |
| `upca`        | UPC A               | Linear          | 12 digits       | Numbers 0–9                                                                         |                                           |
| `upce`        | UPC E               | Linear          | 12 digits       | Numbers 0–9                                                                         | Identical to UPC A in this implementation |

**note:** The function lets you specify some barcode types that aren’t supported. If you specify any of the values in this list, the function doesn’t produce an exception, but it also doesn’t output a barcode.

- `mat25`
- `onecode`
- `plaintext`
- `planet`
- `postnet`
- `telepen`

## Usage

To call the function, pass the string that you want to encode, the barcode type to use, and the width and height of the barcode, along with any optional arguments. Some barcode types, such as EAN 8 or UPC A, only accept a certain number of characters. When you use a non-variable-length barcode type, and you include an incorrect number of characters, the function doesn’t render the barcode.

If you call the function using optional parameters, you must include all of the parameters that precede it. For example, if you want to include the `altText` parameter, you must also include the `checksumValue` and `boolShowText` parameters. In this situation, you can pass empty strings if it's unnecessary to provide a string value. Continuing the example, if it's unnecessary to provide a value for the `checksumValue` parameter because the barcode type you selected includes a checksum by default, you can pass an empty string.

### Basic Usage

To render the barcode, enclose the function code in an HTML `<img>` tag. This example creates a Code 128 Auto barcode that includes the URL of the Salesforce website.

```
<img src="%%=BarcodeURL("https://www.salesforce.com", "code128auto", 150, 50)=%%">
```

The rendered HTML email or landing page includes this barcode.

![A Code 128 Auto barcode, with https://www.salesforce.com printed below it.](https://developer.salesforce.com/docs/media/images/ampscript/mc-ampscript-reference-content-barcode-url-1.png)

### Alternative Text

This example creates a Code 128 Auto barcode in which the encoded data is the URL of the Salesforce website. Rather than print the same text below the barcode, this example uses the `altText` parameter to specify a different printed string.

```
<img src="%%=BarcodeURL("https://www.salesforce.com", "code128auto", 150, 50, "", 0, "Salesforce Website")=%%">
```

**note:** Code 128 Auto barcodes include an internal check digit by default, so you can pass an empty string for the `checksumValue` parameter.

The rendered HTML email or landing page includes this barcode.

![A Code 128 Auto barcode, with the text "Salesforce Website" printed below it.](https://developer.salesforce.com/docs/media/images/ampscript/mc-ampscript-reference-content-barcode-url-2.png)

### Rotation

This example creates a Code 128 Auto barcode that is rotated 90&#176; clockwise.

```
<img src="%%=BarcodeURL("https://www.salesforce.com", "code128auto", 150, 50, "", 0, "Salesforce Website", 90)=%%">
```

The rendered HTML email or landing page includes this barcode.

![A Code 128 Auto barcode, with the text "Salesforce Website" printed below it. The barcode and the text below it are rotated clockwise 90 degrees.](https://developer.salesforce.com/docs/media/images/ampscript/mc-ampscript-reference-content-barcode-url-3.png)
