Skip to content

Instantly share code, notes, and snippets.

@wvpv
Last active June 4, 2019 16:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wvpv/04d4e1a7274e03f25d1f to your computer and use it in GitHub Desktop.
Save wvpv/04d4e1a7274e03f25d1f to your computer and use it in GitHub Desktop.
%%[
var @em, @couponRow, @couponCode
if _messagecontext == "PREVIEW" then
set @couponCode = "XX TEST XX"
else
/* include your sendable attribute/column here */
set @em = AttributeValue("emailAddr")
set @couponRow = ClaimRow("CouponsCodes", "IsClaimed", "EmailAddress", @em)
if empty(@couponRow) then
/* You can do other error handling here if you want.*/
/* This aborts the send */
RaiseError("No coupons available", false)
else
SET @couponCode = Field(@couponRow, "CouponCode")
endif
endif
]%%
Here's your coupon code: %%=v(@couponCode)=%%
@jroobz
Copy link

jroobz commented Jan 25, 2017

Hey Adam

This is really helpful. Thanks for writing up!

Is it possible to supply a unique code to a recipient and then to push it into an intent tweet via AMPScript?

So for example, a recipient would receive their code in an email and then click a 'tweet now' button where a prewritten tweet would display with their unique code in a message.

@wvpv
Copy link
Author

wvpv commented Oct 4, 2018

I suppose you could pass the code into a tweet link:

<a class="twitter-share-button"
  href="https://twitter.com/intent/tweet?text=Here%27s%20your%20coupon%20%%=v(@couponCode)=%%">
Tweet</a>

Details here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment