I am using Monetate (AB platform) to test free shipping on orders over $75 (50/50 traffic split). If a session is in the experiment group, Monetate creates a JS cookie. Is it possible for a Shopify shipping script to recgonize the presence of that JS cookie value?
If so, i want to append that code to this existing prefab script for free UPS ground shipping on orders over $75 -
MINIMUM_ORDER_AMOUNT = 75 #dollars required in cart to get discount
DISCOUNT = 1.0 #percentage discount (in decimal format)
if Input.cart.subtotal_price_was > (Money.new(cents:100) * MINIMUM_ORDER_AMOUNT)
Input.shipping_rates.each do |shipping_rate|
next unless shipping_rate.source == "shopify"
next unless shipping_rate.name == "UPS Ground"
shipping_rate.apply_discount(shipping_rate.price * DISCOUNT, message: MESSAGE)
end
end
Output.shipping_rates = Input.shipping_rates
(I also spliced this one together, one of these should work though, haha.)
MINIMUM_ORDER_AMOUNT = 75 #dollars required in cart to get discount
if Input.cart.subtotal_price_was > (Money.new(cents:100) * MINIMUM_ORDER_AMOUNT)
Input.shipping_rates.each do |shipping_rate|
next unless shipping_rate.source == "shopify"
next unless shipping_rate.name == "UPS Ground"
shipping_rate.apply_discount(shipping_rate.price)
end
Output.shipping_rates = Input.shipping_rates
Thanks!!
Shopify Scripts run on the server before the content is sent to the viewer - so they can't read browser side cookies.
You'll need to approach the A/B testing in a different way. Perhaps by having the A/B script add a custom item to the cart, or a line item property so that Scripts can detect it, passing a 0% discount code, etc.
Here's a couple of options:
I don't know what info you can pull from Monetate to determine if a line item property should be added or not. I'd assume there would be a way to leverage their data to get a simple boolean response.
Thanks Jason.
Can the carrierservice API return rates based on the presence of a cookie? If that were the case, I could have Monetate set a JS cookie for the experiment. You can also modify JS variables and html elements with Monetate for experiment sessions.
Adding a line item to cart is probably not a solution, unfortunately, because we have some custom cart code that won't allow for it.