Skip to main content

Hi everyone 👋

I’ve been stuck on this for weeks and would really appreciate some help to get my forms and events working properly.

Here’s my setup:

  • 🛍️ I’m using Shopify with the Dawn 15.4 theme.
  • ✉️ I’m on the free plan for Klaviyo.
  • 🧾 I added the Klaviyo onsite JavaScript snippet, but since it was limited with my theme, I also added AJAX code so the forms would work properly.
  • ✅ The AJAX code works — I can see Add to Cart events appear in profile activity when I test.

But the problem starts with subscriptions and flows 👇

  • When I test my website:
    1. The popup form appears.
    2. I enter my email and it redirects to my collection page.
    3. I add a product to cart (which should support triggering the flow).
  • ❌ But the email isn’t actually subscribed to my list.
  • ❌ My profile does not show as “subscribed” and doesn’t sync properly.
  • ❌ Because of this, my flows don’t trigger.

I know by default Klaviyo uses double opt-in, but I switched to single opt-in to make it easier.
Even with single opt-in, the profile is still not marked as subscribed.

👉 My goal:
I want the popup form to subscribe the email to my list right away (no double opt-in) and ensure the profile syncs correctly so that my triggered flows actually send.

📸 I’ve attached screenshots of:

  • My form settings
  • AJAX code
  • List settings
  • Flow trigger settings

Any correction if i’m going about it wrong, step-by-step guidance, or best practice advice would mean the world 🙏
Thank you so much in advance for your help.

 

 

<!-- 🟢 Global Klaviyo Snippet -->

<script async src="//static.klaviyo.com/onsite/js/TUkzKA/klaviyo.js"></script>

 

<!-- 🧍 Identify Logged-In Customers -->

{% if customer %}

<script>

window.addEventListener('klaviyo:loaded', function() {

  klaviyo.identify({

    email: '{{ customer.email }}',

    first_name: '{{ customer.first_name }}',

    last_name: '{{ customer.last_name }}'

  });

});

</script>

{% endif %}

 

<!-- 🛒 Add to Cart + Checkout Tracking -->

<script>

document.addEventListener('DOMContentLoaded', function () {

  window.addEventListener('klaviyo:loaded', function () {

 

    // ✅ Add to Cart tracking (works with Dawn AJAX cart)

    document.addEventListener('submit', function (e) {

      if (e.target.matches('form[action*="/cart/add"]')) {

        e.target.addEventListener('formdata', function (event) {

          const formData = event.formData;

          const variantId = formData.get('id');

          const quantity = formData.get('quantity') || 1;

 

          // You can add more product details if needed

          klaviyo.track('Added to Cart', {

            'Product ID': variantId,

            'Quantity': quantity

          });

        });

      }

    });

 

    // 🧾 Started Checkout

    document.querySelectorAll('button[name="checkout"], a[href*="/checkout"]').forEach(function (btn) {

      btn.addEventListener('click', function () {

        klaviyo.track('Started Checkout', {

          'Cart Items': {{ cart.items | json }},

          'Cart Total': {{ cart.total_price | money_without_currency }}

        });

      });

    });

 

  });

});

</script>


 

thank you so much in advance!

@Fiona Lu thank you for the detailed input.  While I can see that you have added code specifically to fire the Added to Cart event and it seems to work correctly but I am not seeing any invocation of the client subscription api call.  More details about it in the link below: