2

We use AMPScript to deliver coupon codes to our Clients at the BU level from a DE.

The one thing I need is a way to automatically send me a message when any of the DE containing the codes falls below 5% so I can replenish the codes across 40 BU's.

1
  • To have it run conditionally would likely require some SSJS. My experience with similar cases is to just create an email campaign that runs daily (twice daily even) that sends you and interested parties the number of non claimed coupon codes. Commented Dec 9, 2014 at 18:56

2 Answers 2

2

I've used a data extension, query, an email and a daily automation as an alert system. The data extension is for storing the coupon counts, the query populates the counts and the email contains the threshold logic. If the alert criteria is not met, the email send aborts. You can set the alert audience in a list that's defined in your user-initiated send definition.

Here's the scripting for the email:

%%[

var @rows, @number_Available, @number_Claimed, @total, @runDate

set @rows = LookupRows("Coupon_Codes","Active",1)
set @number_Available = Field(Row(@rows,1),"Number_Available")
set @number_Claimed = Field(Row(@rows,1),"Number_Claimed")
set @total = Field(Row(@rows,1),"Total")
set @runDate = Field(Row(@rows,1),"RunDate")

if @number_Available > 6000 then
  raiseerror("Has not met threshold for alert", true)
endif

]%%

<div style="font-family:sans-serif; font-size:0.8em;">

    <h3> Coupon Code Alert</h3>

    <p>The unused coupon count has fallen below 6000.</p>

    <p>Data Extensions &gt; Coupon_Codes</p>

    <table cellspacing="0" cellpadding="3" border="0">
        <tr><td><b>Run Date</b></td><td>%%=v(@runDate)=%%</td></tr>
        <tr><td><b>Available</b></td><td>%%=v(@number_Available)=%%</td></tr>
        <tr><td><b>Claimed</b></td><td>%%=v(@number_claimed)=%%</td></tr>
        <tr><td><b>Total</b></td><td>%%=v(@total)=%%</td></tr>
    </table><br/>
    <br/>
    This email was sent by:<br/>
    <b>%%Member_Busname%%</b><br/>
    %%Member_Addr%% %%Member_City%%, %%Member_State%%, %%Member_PostalCode%%, %%Member_Country%%<br/>
    <a style="font-size:0.75em; font-family:sans-serif;" href="%%profile_center_url%%" alias="Update Profile">Update Profile</a>
</div>
<custom name="opencounter" type="tracking">
2
  • Please let us know how it turns out. Commented Dec 9, 2014 at 19:59
  • here's what i simply need is the total. I'm us '@' to get the symbol in my reply. I have one field which is a total number of unclaimed in this DE %%[ var '@'rows, '@'total set '@'rows = LookupRows("SEVN_Codes_Left_v2","total",1) set '@'total = Field(Row('@'rows,1),"Total_Claimed") if '@'Total_Claimed > 6000 then raiseerror("Has not met threshold for alert", true) endif ]%%
    – Jeffrey
    Commented Dec 10, 2014 at 16:48
0

I know that is not the topic, but it can be useful. I got an automation in automation studio with a SQL activity that gets all the active coupons into another data extension updating daily.

After that I got a step 2 with a Verification activity pointing to the DE of step 1, that sends me an email if the DE got 1000 active coupons or less.

The cool thing about the verification activity is that you can set the email there with no code.

More info here:

https://help.salesforce.com/s/articleView?id=sf.mc_as_verification_activity.htm&type=5

Omar

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .