In addition to the installation mentioned in the previous article. You will need to add an additional script to your JavaScript file of the template you use for your website.
These script will enable you to pass the data whenever there is an event of add to cart and add to wishlist from the category pages or product list pages or product module block.
Adding these script via ocmod is not possible and also adding this script within the module is not a practical solution. The effective way is to add it directly to main template JavaScript file involved.
For default theme, the JavaScript file is located at
catalog/view/javascript/common.js
You will have to identify the function responsible for add to cart and add to wishlist events and add the following script respectively, just after the json[‘success’] call
Script 1:
//KLAVIYO ADDED TO CART $.ajax({ url: 'index.php?route=module/klaviyo/added_to_cart&product_id='+product_id+'&quantity='+ (typeof(quantity) != 'undefined' ? quantity : 1), type: 'post', dataType: 'json', success: function(json) { console.log(json['klaviyo_addtocart_items']); klaviyo.push(["track", "Added to Cart", json['klaviyo_addtocart_items']]); } }); //KLAVIYO ADDED TO CART
Script 2:
//KLAVIYO ADD TO WISHLIST $.ajax({ url: 'index.php?route=module/klaviyo/added_to_wishlist&product_id='+product_id, type: 'post', dataType: 'json', success: function(json) { console.log(json['klaviyo_wishlisted_items']); klaviyo.push(["track", "Added to Wishlist", json['klaviyo_wishlisted_items']]); } }); //KLAVIYO ADD TO WISHLIST END
Feel free to contact us for the installation help. Submit a support ticket in https://www.huntbee.com/get-support
For Journal2 Template, the file is
catalog/view/theme/journal2/js/journal.js
For Jouranl3 Template, the file is
catalog/view/theme/journal3/js/common.js
Feel free to contact us for the installation help. Submit a support ticket in https://www.huntbee.com/get-support