How to Add a Barcode to Documents and Emails
Document Studio can put a different barcode in every email and document it creates. Use a barcode for anything a scanner reads at a counter: gift cards, membership numbers, vouchers, parcel labels or library cards. The number comes from your Google Sheet or form response.
You can add the barcode in two ways. An Embed Barcode marker in your template needs no extra column. A BARCODE formula in your sheet lets you see every barcode before the workflow runs.
Send a Gift Card Barcode to Each Customer
Section titled “Send a Gift Card Barcode to Each Customer”Maya Chen sells gift cards for her workshops at Willow Lane Studio. Her front desk has a barcode scanner, so each gift card number should arrive as a barcode that staff can scan from the customer’s phone.
| First Name | Email Address | Gift Card | Value |
|---|---|---|---|
| Daniel | daniel.okafor@example.net |
WL-2048-1175 | $50 |
| Hannah | hannah.weber@example.org |
WL-2048-1176 | $75 |
-
Open the workflow and add a Send Email task, or open the one you have.
-
In Email Body, type an
Embed Barcodemarker on a line of its own, where the barcode should appear.Hi {{First Name}},Here's your {{Value}} gift card for any workshop at Willow Lane Studio.Show this barcode at the front desk:{{Embed Barcode, {{Gift Card}}, format=Code 128}}Maya -
Click Preview. Document Studio sends the email to your own address with sample data. Scan the barcode with the scanner you’ll use at the desk.
-
Click Done, then save the workflow.
Daniel’s email shows the barcode for WL-2048-1175, with the number printed below the bars in case the scanner is busy. If you leave out format=, the barcode is Code 128.

Document Studio attaches the barcode inside the email, so it shows even in email apps that hide pictures from the web.
Add a Barcode to a Document
Section titled “Add a Barcode to a Document”The same marker works in a Google Docs, Slides or Sheets template. Maya can make a printable gift card in Google Docs with the same barcode as the email.
| Template | Where to type the marker | What happens |
|---|---|---|
| Google Docs | On a line of its own | The barcode replaces the marker |
| Google Slides | Alone in a text box | The barcode replaces the whole text box and fits inside it |
| Google Sheets | Alone in a cell | The barcode sits over the cell. Spaces or a line break around the marker are fine, but no other text. |
In Google Docs and Sheets, Document Studio shrinks a barcode wider or taller than 600 pixels to fit. A PDF made from the document includes the barcode.

Say What the Barcode Holds
Section titled “Say What the Barcode Holds”You can write the value after Embed Barcode, in three ways:
| You write | The barcode holds | If the title is misspelled |
|---|---|---|
{{Embed Barcode, {{Gift Card}}}} |
The Gift Card cell of that row | No barcode |
{{Embed Barcode, Gift Card}} |
The Gift Card cell of that row | A barcode of the misspelled title |
{{Embed Barcode, "WL-2048, Studio"}} |
The text in quotes, exactly as typed |
Use braces for a column of your sheet or a question of your form. Use quotes for text you type, and always for text with a comma, because a comma starts the options. Markers inside quotes are filled in for each row, like "{{First Name}}, seat {{Seat}}". When the cell is empty, Document Studio adds no barcode.
| Use | Marker |
|---|---|
| A gift card or voucher number | {{Embed Barcode, {{Gift Card}}, format=Code 128}} |
| A book number from a form question | {{Embed Barcode, {{Enter Book ISBN}}, format=EAN-13}} |
| A parcel label, short and without the number below | {{Embed Barcode, {{Order Number}}, height=10, includetext=false}} |
| A format that is different for each row | {{Embed Barcode, {{Code}}, format={{Barcode Type}}}} |
Choose a Barcode Format
Section titled “Choose a Barcode Format”Pick the format your scanner or system expects. If only your own staff scan the number, use Code 128. Code 128 takes letters, digits and symbols, and almost every scanner reads it.
| Format | Write it as | What it holds | Common use |
|---|---|---|---|
| Code 128 | format=Code 128 |
Letters, digits and symbols | Gift cards, order numbers, tickets |
| Code 39 | format=Code 39 |
Capital letters, digits and a few symbols | Name badges, inventory tags |
| EAN-13 | format=EAN-13 |
12 or 13 digits | Products sold in shops, books |
| UPC-A | format=UPC-A |
11 or 12 digits | Products sold in the US and Canada |
| ISBN | format=ISBN |
A book number with hyphens, like 978-1-78633-089-5 | Books |
| Data Matrix | format=Data Matrix |
Letters, digits and symbols, in a small square | Parts, lab samples, small labels |
Capital letters, spaces and hyphens in the format name don’t matter, so format=code128 and format=Code 128 are the same. For a book number without hyphens, use EAN-13.
Document Studio knows more than 100 formats, including postal and pharmacy codes. See the full list of formats.
Data Matrix packs the same text into a small square. Add scale=6 to make it twice as big. For a code that every phone camera opens, use a QR code.
Change the Size and Color
Section titled “Change the Size and Color”Write options after the text, with a comma before each one:
{{Embed Barcode, {{Gift Card}}, format=Code 128, height=10, barcolor=#1A3C6E}}| Option | What it does | If you leave it out |
|---|---|---|
format |
The barcode format | Code 128 |
height |
Height of the bars in millimeters | 20 |
scale |
Size of the whole picture. 6 is twice as big. |
3 |
includetext |
Prints the text below the bars. Use includetext=false to hide it. |
Shown |
rotate |
R turns the barcode right, L left and I upside down |
Not turned |
barcolor |
Color of the bars, as a hex code | Black |
textcolor |
Color of the printed text, as a hex code | Black |
backgroundcolor |
Color behind the bars, as a hex code | See-through |
Scanners need strong contrast, so keep the bars dark. Add backgroundcolor=#FFFFFF if your readers use dark mode. Pictures are limited to 2000 by 2000 pixels. See the full list of options.
Use the BARCODE Formula in Your Sheet
Section titled “Use the BARCODE Formula in Your Sheet”Document Studio adds a BARCODE function to Google Sheets. The formula turns each row’s number into a link to a picture of the barcode.
-
Add a column titled Barcode to your sheet.
-
Click the first cell under the title and paste this formula. C2 is the cell with the gift card number.
=BARCODE(C2, "Code 128")Outputhttps://charts.digitalinspiration.com/barcode/3TnLwPmD0RF0aPWf1LJCyfp1kgG1me2UoPWL4.pngThe cell shows a long link that ends in
.png. That link is the picture of the barcode. -
Copy the formula to the other rows. Click the cell, then drag the small blue square at its bottom-right corner down to the last row.
-
To see the barcodes in the sheet, add a column titled Barcode Preview. Enter
=IMAGE(E2), where E2 is the cell with the link, and copy the formula down. -
In your template, type
{{Barcode}}where the barcode should go.
The formula needs the format. Options go in a third value, in quotes, with a space between them, like =BARCODE(C2, "Code 128", "height=10 includetext=false").
Use the column with the link in your template, not the preview column. Document Studio shows a {{Barcode}} marker as the picture in emails, Google Docs, Slides and Sheets. In an email, the picture loads from charts.digitalinspiration.com when the reader opens the email.
Things to Know
Section titled “Things to Know”- Without
format=, barcodes are Code 128. Older versions of Document Studio made Code 39. - Older email templates may have
=BARCODE({{Gift Card}} format=Code128)typed in the Email Body. This still works in emails only. Use anEmbed Barcodemarker in new templates. - A barcode on a phone screen scans best at full brightness. Tell customers to turn the brightness up, or to print the email.
- Give every row a different number. If a formula like
RANDBETWEENmakes your numbers, the numbers change each time the sheet recalculates. Copy them and paste them as values before the workflow runs. - Document Studio removes the marker from the email Subject and from text messages, such as SMS and Google Chat.
- A marker inside an
{% if %}condition adds the barcode only when the condition is true.
Troubleshooting
Section titled “Troubleshooting”The barcode is blank, or missing from the email
Section titled “The barcode is blank, or missing from the email”The value doesn’t fit the format. EAN-13 and UPC-A take digits only, and the last digit must be the right check digit. Code 39 doesn’t take small letters, and Codabar needs a letter from A to D at each end. Fix the value, or switch to Code 128. Also check that the cell isn’t empty for that row.
The barcode shows a column title
Section titled “The barcode shows a column title”The marker has no braces around the column title, like {{Embed Barcode, Gift Card}}, and no column has that title. Write {{Embed Barcode, {{Gift Card}}}} and check the spelling.
The barcode holds only part of the text
Section titled “The barcode holds only part of the text”The text has a comma, so Document Studio read the rest as options. Put the text in quotes, like {{Embed Barcode, "WL-2048, Studio"}}.
The barcode is Code 128, not the format you asked for
Section titled “The barcode is Code 128, not the format you asked for”Document Studio doesn’t know the format name, so it drew Code 128, the same as when you leave format= out. Check the spelling against the list of formats.
The cell with the formula is empty
Section titled “The cell with the formula is empty”The BARCODE formula needs both the number and the format. Check that the cell the formula points to has a value, and that the format name is in the format table.
The cell shows #NAME?
Section titled “The cell shows #NAME?”Google Sheets doesn’t know the BARCODE formula yet. Open the Extensions menu and choose Document Studio > Open once in this spreadsheet, then close the sidebar. The formula works after that.
