Challenge
https://ampscript30.com/ampscript-challenge-day9/
To provide random discounts to each customer.
Solution
%%[
SET @email = Email
SET @name = Concat(FirstName, ' ', LastName)
SET @discount = Random(10, 50)
InsertDE('AMPscript30 - Day 9 Random Discount WriteIN', 'FirstName', FirstName, 'LastName', LastName, 'Email', Email, 'Discount', @discount)
]%%
Hello %%=v(@name)=%%,
Are you ready for some shopping? Today, we are offering our subscribers a special discount on their next purchase.
Your discount is: %%=v(@discount)=%%%

Preview


Summary
When writing data to a Data Extension, it’s a good practice to always capture the Subscriber Key or even the Send Job ID.