App reviews, troubleshooting, and recommendations
Hello, please help me to add the Added to card event snipper from Klaviyo, so I can send following up emails. I tried everything from their help article but nothing works. Thank you.
@YordanBYou need to use following script if you have Mini Cart enabled in Dawn Theme and the product is added to the mini cart instead of redirecting the user to the Checkout Page when "Add to Cart" button is clicked.
<script type="text/javascript">
var _learnq = _learnq || [];
function addedToCart() {
fetch(`${window.location.origin}/cart.js`)
.then(res => res.clone().json().then(data => {
var cart = {
total_price: data.total_price/100,
$value: data.total_price/100,
total_discount: data.total_discount,
original_total_price: data.original_total_price/100,
items: data.items
}
if (item !== 'undefined') {
cart = Object.assign(cart, item)
}
_learnq.push(['track', 'Added to Cart', cart])
}))
}
(function (ns, fetch) {
ns.fetch = function() {
const response = fetch.apply(this, arguments);
response.then(res => {
if (`${window.location.origin}/cart/add.js`
.includes(res.url)) {
addedToCart()
}
});
return response
}
}(window, window.fetch))
$(document).ajaxComplete(function(event, request, settings){
if(settings.url == "/cart/add.js"){
addedToCart()
}
})</script>
You need to edit the Default Product Page Template and add a Custom Liquid block and then add above script in that.
After you are done doing that... Test the event by force cooking an email id for which a profile in Klaviyo doesn't exists already by something like this domain.com?utm_email=testemail@emailhost.com (replace domain.com with your domain name and testemail@emailhost.com with your test email id). Add the URL in your browser window and enter URL > Navigate to Product Page > Add Product to Cart.
Look for the profile with this email id in Klaviyo and if you see that then the Event Tracking is working.
And, finally go back to your Flow, add Add to Cart Tigger and Complete it.
This worked for me! thank you!
Great! Please accept the solution to help others!
Hi, I've been testing and this is still not working on my end. Not sure why. Cheers, Daniel
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024