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:
- The popup form appears.
- I enter my email and it redirects to my collection page.
- 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!