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!
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023