Skip to main content

Cashback - Capturing Opt-ins from a Popup

How to let customers opt in to a cashback offer from a popup or sign-up form, using any popup tool.

Written by Kris James

The Mage Loyalty app embed must be enabled on your live Shopify theme for opt-in capture to work.

What are Opt-in Offers?

You can use cashback offers as an incentive to ask a customer to opt in before their order qualifies. This is useful for promotions like "Enter your email to get $20 back on your first order". The customer opts in through a popup or sign-up form, and then their first qualifying order earns the cashback.

You turn this on with the Require opt-in setting when you create or edit a cashback offer.

Opting in works with any popup or form tool that lets you run a small piece of code when the form is submitted, or lets you add a snippet to your theme. It is not tied to any specific provider.


How Opt-in Capture Works

  1. You give the cashback offer an identifier.

  2. You connect your popup or form to Mage with a single line of code that passes the identifier and the customer's email.

  3. When a customer submits the form, that email is opted in to the offer.

  4. When the same customer later places a qualifying order with that email, the cashback is earned and follows the normal approval flow.


Step 1: Set Up the Offer

  1. In the Mage Loyalty app, open Cashback and create or edit an offer.

  2. Turn on Require opt-in.

  3. Enter an Opt-in identifier. Use letters, numbers and dashes, for example first-purchase-20. This is how your popup refers to this offer.

  4. Make sure the offer's Status is Active.

  5. Click Save.


Step 2: Connect Your Popup

The app embed installs a helper on every page of your storefront called window.MageLoyalty.cashbackOptIn. Call it from your popup tool's submit hook (the place where you can run custom code when the form is submitted), passing the offer identifier and the customer's email:

window.MageLoyalty.cashbackOptIn('first-purchase-20', email)

Replace first-purchase-20 with your offer's identifier, and email with the email address the customer entered.


Example: Klaviyo

Klaviyo sign-up forms send an event to the page when they are submitted. You can listen for that event and pass the email to Mage. Add this snippet to your theme (for example in theme.liquid) or in Klaviyo's onsite custom code:

<script>
  window.addEventListener('klaviyoForms', function (e) {
    if (e.detail.type === 'submit') {
      window.MageLoyalty.cashbackOptIn(
        'first-purchase-20',
        e.detail.metaData && e.detail.metaData.$email
      );
    }
  });
</script>

Replace first-purchase-20 with your offer's identifier. The same approach works for other popup tools: call window.MageLoyalty.cashbackOptIn from wherever that tool lets you run code on form submit.


How the Cashback is Earned

Opting in does not award anything on its own. After opting in, the customer still needs to place an order that meets all of the offer's conditions, such as the schedule, the minimum order amount, the new customer rule, and any segment targeting.

When they place a qualifying order using the same email they opted in with, the cashback is earned and moves through the normal approval flow described in Cashback - Overview & Setting Up an Offer.


Checklist

  • The Mage Loyalty app embed is enabled on your live theme.

  • The offer is Active, has Require opt-in turned on, and has an identifier.

  • Your popup passes the same identifier and the customer's email to window.MageLoyalty.cashbackOptIn.


Troubleshooting

Opt-ins are not being recorded

  • Confirm the Mage Loyalty app embed is enabled on your current live theme.

  • Check that the identifier in your code matches the offer's identifier exactly.

  • Check that the customer's email is actually being passed into the call.

The customer opted in but did not earn cashback

  • Confirm they placed an order using the same email they opted in with.

  • Confirm the order met the offer's other conditions, such as the minimum order amount, the schedule, and any new customer or segment rules.

Did this answer your question?