Shopify / buy-button-js

BuyButton.js is a highly customizable UI library for adding ecommerce functionality to any website.
http://shopify.github.io/buy-button-js/
MIT License
242 stars 114 forks source link

I'm using DOMEvents on a button for tracking - how do I add the event back to go to checkout? #801

Open jasonbraun opened 2 years ago

jasonbraun commented 2 years ago

I need to add an AddToCart event to a buy button for FB Pixel tracking - when I use DOMEvents to add it like this:

"product": {
  "DOMEvents": {
    'click .shopify-buy__btn': function () {
      fbq('track', 'AddToCart');
    }
},

That overrides the default click event of going to checkout - is there a way to add the event back? I've looked through the docs and past issues here and can't find anything. I saw ui.openCart() mentioned, but I want the button to go directly to the checkout page instead.

rorybokser commented 1 year ago

Was there ever a conclusion here? I'm facing the same issue now.

rplakas commented 1 year ago

"DOMEvents": { 'click .shopify-buybtn-wrapper .shopify-buybtn': function (evt, target) {

fbq('track', 'AddToCart', {