A|B testing pricing / discounts in line-item scripts?

New Member
1 0 0

Hey all, 

We're looking to test a "5 for $50" upsell feature, and we only want to activate it for some subset of customers to our site. We are using Google Optimize and would like to have some JavaScript execute when a user first lands on our storefront to set some flag on either the customer or the cart that we can then key off of in our line-item scripts to decide whether or not to discount items.

We've tried and thought about a few things:

  • Our prices range from $10-15 per item, so the total discount is dynamic and I don't see a way to generate flat discount codes on the fly, or apply them to a cart.
  • Our understanding is we need to apply the discount per-line-item in a line-item script, which we only want to do to a subset of users, so can only work with info available in the scripts directly.
  • Since we allow anonymous checkout, I don't believe tagging the customer is an option (nor do I see a way to update the customer record via client-side APIs anyway). 
  • I don't see a way to annotate the cart itself w/ extra metadata or attributes that we could use in the scripts.
  • We could potentially use the "cart.notes" field, but that feels like an abuse.


Has anybody had success impelmenting something like this in the past? Appreciate any help!



Shopify Expert
10360 158 2003

You could look into using Line Item Properties to help trigger the discount since those values can be read with Shopify Scripts.

Word of caution here hoever - it's not impossible for customers to add their own values when adding items to the cart. This means if you're adding the actual discount into the LIP, then it can be exploited.

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.

★ http://freakdesign.com.au ★