How to correctly track button clicks in Big Cartel (with Facebook pixel)

269 Views Asked by At

I'm stuck with setting up correctly FB pixel code, events like page view and content view work fine, but seems I missing something with tracking button clicks like "AdToCart" or "InitiateCheckout" events. Tried to play with a code, but didn't figure out it.

Here is the original code I tried to implement from Facebook for Add to Cart event.

<script>
<button id="button add-to-cart-button">AddtoCart</button>
<script type="text/javascript">
  $('#addToCartButton').click(function() {
    fbq('track', 'AddToCart', {currency: "EUR", value: {{ option.price }}});
  });
</script>

What am I doing wrong?

1

There are 1 best solutions below

0
Flavius On

First, you cannot have multiple ids to one element. The id is unique, so id="add-to-cart-button"

Second, the id is 'add-to-cart-button', so the jquery selector should match that: #add-to-cart-button not #addToCartButton