02 / 06
AMPscript & Personalization
Writing AMPscript for personalized subject lines and conditional content, and setting up A/B tests.
%%[ SET @tier = AttributeValue("LoyaltyTier") SET @name = ProperCase(AttributeValue("FirstName")) IF @tier == "Icon" THEN SET @hdr = "Your Icon perks are here" ELSE SET @hdr = "Earn more with every order" ENDIF ]%% <!-- %%=v(@name)=%%, %%=v(@hdr)=%% -->
| Version | Testing |
|---|---|
| A | Subject line |
| B | Subject line |
| C | From name |
| D | Hero image |
- AMPscriptpersonalization
- A/Bsubject, from name, images
- 1template, many versions
The job
Customers got different content depending on brand, loyalty tier and region. The same template had to handle every version.
What I did
- Wrote AMPscript for personalized subject lines and conditional content
- Set up A/B tests on subject lines, from names, images and Movable Ink content
- Used data extension fields to drive dynamic content
- Worked with SQL queries from the data team for audience segmentation
- Checked every version on test sends before handoff
Personalization, up close
One template served many customers. AMPscript read each customer’s data at send time and decided what they saw: their name, their balance, their department and their language.
Values like saved cart items came from a separate data extension, matched on the customer’s key.
A shopper’s department (women, men, kids, baby) decided which version of the email they got.
See it working
An A/B test rebuilt from the original Gap Factory assets: the same offer with two subject lines, two preheaders and two hero images. Version B puts the customer’s first name in the subject line, with a fallback when it’s missing.
How I built it
- Wrote subject lines with a fallback when a first name was missing
- Used IF / ELSEIF to switch content by segment and department
- Used Lookup to pull values from other data extensions
- Split audiences for tests, such as 33/33/34 across three versions
- Claimed unique promo codes per customer with ClaimRow
A line from the code
%%[ if @adhoc5 == "WMN" or @adhoc5 == "MAT" then
set @adhoc_evo_append = "WOMEN"
elseif @adhoc5 == "MEN" then
set @adhoc_evo_append = "MEN"
else
set @adhoc_evo_append = "ROF"
endif ]%%
A shop-by-size email picked its version from the shopper’s department. Anyone outside the main groups got the general version.
How I checked it
- Built a test record for every branch, including missing data
- Previewed each version as a test subscriber before handoff
- Checked test splits added up and each version reached its group
How it helped
One template could cover many customer versions, which cut down on separate builds and kept content consistent.
Skills used
- AMPscript
- Personalization
- A/B testing
- Data extensions
- SQL
- Dynamic content