This case study has been published as a part of the official Solution Guide in the Salesforce Marketing Cloud documentation.
Barcodes are found on every product in any type of a store. Black and white parallel lines and mosaic QR codes are not only present in the brick and mortar world but became ubiquitous in a virtual and augmented reality. E-tickets, boarding passes, points of interest or mobile games such as Pokemon Go applied barcode technology to encode and share information.
Salesforce Marketing Cloud users can also leverage the barcode technology for personalized email marketing. The AMPScript has a content function to generating barcodes using supplied information. In other words, no need to search for a ‘barcode generator’ to include a zebra stamp in your ticket confirmation emails.
Create a Scannable E-ticket Using SFMC Email Studio
If you use a fully fledged online registration system, it is likely that you are freed from any post registration manual work. It was different in my case. I was asked by an event organizer for help in creating confirmation emails that could be scanned by staff at a registration point directly from a participant’s mobile phone screen.
Each attendee who purchased a ticket online had a unique ticket number assigned. Participant’s name and email address were captured with the online registration form. The online form was not integrated with SFMC so all collected data (around 300 participants) was manually imported to a sendable Data Extension. Then, I built a personalized, confirmation email with the unique ticket number encoded into a barcode image. The event organizer sent those emails to the Data Extension after the online registration was closed.
Data Extension Structure
Each DE field is set to 128-character long Text except the email address (EmailAddress).
SubscriberKey | FirstName | LastName | Barcode | |
john@gmail.com | 12345-john@gmail.com | John | Brown | OKVKTZ0K9O |
kim@yahoo.com | 67890-kim@yahoo.com | Kim | Kardashian | HYW1D8XXDU |
ben@outlook.com | 54321-ben@outlook.com | Ben | Hur | 31FPTXMR6I |
robert@gmail.com | 09876-robert@gmail.com | Robert | Lee | 0OAHFSCGG4 |
AMPScript Snippet for the Dynamic Email
The SFMC help documentation describes the BarcodeURL function and its parameters with all necessary details and examples. You can choose among multiple barcode types.
For the e-ticket scanned from a mobile phone, I chose the Code128Auto, because it supports any ASCII character (the ticket number combined letters and digits) and it encodes data with the shortest possible number of bars (a high density code). It is narrower than for example Code39. The Code128 is probably the most common barcode you can find.
I adjusted the width and height to 300 and 100 pixels respectively. The barcode image I used was the default black and white it is recommended to use the highest contrast possible for faster scanning from a screen.
%%[
var @barcode, @ticket, @firstName, @lastName, @fullName
set @ticket = AttributeValue("Barcode")
set @fullName = Concat(@firstName," ",@lastName)
set @barcode = BarcodeURL(@ticket, "Code128Auto", 300, 100)
]%%
Barcode and Dynamic Content for the Email Body
The BarcodeURL function generates a PNG image, with specified dimensions, at a time of the send. As per the documentation, place the image tag and set the source attribute to the function’s value.
<p>Name: %%=v(@fullName)=%%</p>
<p>Ticket Number: %%=v(@ticket)=%%</p>
<p><img src="%%=v(@barcode)=%%"></p>
Final Result
About Barcode Technology
- The barcode was invented by Norman Joseph Woodland and Bernard Silver and patented in the US in 1951.
- Woodland mentioned that an inspiration came from Morse code: “I just extended the dots and dashes downwards and made narrow lines and wide lines out of them.”
- Initially different forms of codes and scanning technologies were tested on railroad cars.
- In early days of barcode popularization, groceries did not see them as cost savers.
- Due to expensive scanners, the prospects for a wide use of barcodes in retail were not promising.
- In a 1976 article, Business Week proclaimed “The Supermarket Scanner That Failed”.
- The very first scanned product was a pack of Wrigley chewing gum in June 1974.
- A good friend of mine has a Fibonacci sequence tattooed at his forearm in a form of barcode lines.
Barcode Scanners
Before the smartphone era, barcode scanners were physical devices only. Some highly specialized and integrated into sophisticated ecosystems for example in retail, warehouse management or logistics.
Nowadays, for basic barcode or QR code scanning you can download a free app or use a built-in camera function on your smartphone (starting from iOS 11 or Android 9 with Google Lens Suggestions activated).