How to add the event snippet Added to cart event from Klaviyo on Dawn Theme

37 1 4

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. 



Replies 4 (4)

Shopify Partner
12 1 6

@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() {
  .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)) {
    return response
}(window, window.fetch))
$(document).ajaxComplete(function(event, request, settings){
  if(settings.url == "/cart/add.js"){

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 (replace with your domain name and 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.


1 0 0

This worked for me! thank you!

Shopify Partner
12 1 6

Great! Please accept the solution to help others!

New Member
10 0 0

Hi, I've been testing and this is still not working on my end. Not sure why. Cheers, Daniel