How to Create a Custom "Added to Cart" & "Viewed Product" Event for Magneto2

  • 19 January 2021
  • 4 replies

Badge +7


Does anyone have the snippet of code that is need for the added to cart & viewed product event for Magneto. I can find shopify and Bigcommerce.


Many thanks



Best answer by Paul S 20 January 2021, 19:21

View original

4 replies

Userlevel 5
Badge +10

Hi @davemanson 


So the reason you’re able to find documentation for Shopify and BigCommerce Added to Cart and Viewed Product but not Magento is that we do not have a built-in or copy-paste Added to Cart snippet for Magento.


Even though we don’t have something that can be copied and pasted like for Shopify or BigCommerce, you can still get this set up but this is something that the business will need to set up using our Javascript Track API.

The process (and most likely the snippet you’re looking for) is similar to the process for Shopify and BigCommerce meaning listening for a person clicking on the “add to cart” button and then sending the Viewed Product payload as an Added to Cart event.


I would definitely recommend passing this information along to whatever developer resources you have available so that they can take a look and get this set up. 

Badge +7

Brilliant thank you

Userlevel 7
Badge +44

@davemanson additionally if you have GTM with Google Analytics setup you could leverage the same data to send an event to Klaviyo (using GTM).

If not it's basically triggering a script when someones clicks on the add to cart button that sends related information (product info) to Klaviyo using what @Paul S mentioned.

Badge +1

Brilliant thank you

How did you achieved that? i also want to do something similar like that.