'Random' tag assigned to order

Solved

'Random' tag assigned to order

MR-Kees
Shopify Partner
2 0 0

Hi!

I'm wondering if there is a way to 'randomly' assign 1 of 2 specific tags to an order using Flow.

The use case here is that we want to randomly send specific inserts in our orders to then see if there's a difference in these customers' shopping behaviour later, where we can use the order tag to bucket the customers.

 

So, we'd have a flow that on order creation sets 1 of N (in our case 2) possible order tags.

That would be all (our logistics partner handles the rest).

 

Any ideas on how to accomplish this? I know that the Run Code action does not support math.random so any alternative solutions to this are appreciated. 

 

Thanks!

Accepted Solution (1)
RPiii
Shopify Staff
145 26 43

This is an accepted solution.

Run code would let you use Javascript to code something to manipulate the string and evaluate the result.

View solution in original post

Replies 3 (3)

RPiii
Shopify Staff
145 26 43

Since you only need it to be psuedo-random, maybe using Run code to check if order.createdAt is even or odd might be sufficient?

MR-Kees
Shopify Partner
2 0 0

Good shout!

AFAIK this would look like "2019-09-07T15:50:00Z", correct?

Would you recommend looking at a specific part (i.e. the seconds) of the DateTime, or is there a way to convert to Epoch/Unix timestamp to get a number that is checkable for even/odd?

Not sure exactly what is available in Run code, haven't used it yet.

Thanks!

RPiii
Shopify Staff
145 26 43

This is an accepted solution.

Run code would let you use Javascript to code something to manipulate the string and evaluate the result.