I need to send an email every time a customer spends an accumulated $100.
I have the connector for the email program set.
"LifetimeValue" is being added to a stored Number per visitor for every transaction.
A second number called "Spend100" is also tallying the total spend
What I need to do in order is:
Can someone advise how to do part 2?
So I need to...
How do I ensure that these steps happen in the correct order?
Can I ask a couple of questions to help you?
1. What do you want to happen if the user places an order for say $250?
2. What do you want to happen if the user places several orders in the same visit?
3. For your setup, would you be able to offload some of the logic to Tealium iQ (client-side)?
4. Is there a timeframe on the offer? If the user spent $95 six months ago and is now spending $10, do you still want to trigger the offer?
All very good questions!
UDH does not currently have the mathematical operators of Floor/Celing, Integer Division and Modulus/Remainder, which would be needed here to do this in pure UDH. I encourage you to please submit a product idea to add those enrichments on the Number Attribute.
So since we can use iQ here, I'd suggest the following approach;
1. Make sure Data Layer Enrichment (DLE) is swtiched on for the collect tag, at least on the order confirmation page and the first page of a users session as well as when they log in. You can selectively control this if you don't want to have it run on every page, but be sure that the visitors lifetime order value is coming back via DLE at the correct point.
2. Add a JS extension scoped to the collect tag, conditional on the order confirmation page, with this kind of code;
//get the current order lifetime value and work out how many integer multiples of 100 it is
var previous = b && b['va.metrics.5019'] ? b['va.metrics.5019'] : 0; var previous100 = Math.floor(previous/100);
//add on the current order value and again work out integer multiples of 100 it is var now = previous + (b.order_total || 0); var now100 = Math.floor(now/100);
//work out how many integer multiple boundaries we have crossed b.as_100_crossed = (now100 - previous100).toString();
You will need to replace 5019 with the ID of your visitor lifeitme order total number in AS. You may also need to replace order_total with whatever the variable name is in your data layer for the current order value.
Now in UDH, you can add an event level number called "as_100_crossed" and this gives you for the current order, how many times the visitor has crossed the $100 threshold on this order value.
Make sure that either in your iQ publish settings that code minification is turned on, or else remove the comments yourself from the above code.
Ah, that's why I asked if you could offload the logic into iQ.
For pure UDH, you do have some options.
Assuming that you don't want to change your logic at all, and without the enhancements discussed above, there are some ways, for example;
You'll see that with this approach, it is bounded. You need to create the $100 bins manually, and the approach will eventually stop working because you can only create a finite number of them. I created 3 in the example above.
The above approach is designed to trigger immediately on a threshold. If you want to wait for the end of the visit to do so instead, then make the final boolean visit scoped, and remove the set false enrichment from it.
I will go now and create an internal product idea for you for the necessary enrichments, but you should also create your own public facing one.