Skip to main content
All CollectionsTechnical Knowledge basePixel Management
Setting up your Pixel: Inline Actions
Setting up your Pixel: Inline Actions

Want to have your "Add to Cart" event linked to a button? Learn how here!

Orel Gilad avatar
Written by Orel Gilad
Updated over 6 years ago

The standard way to trigger a pixel is to put the event on a page and when the page is loaded, the event will be triggered. 

Sometimes, you may need to trigger events when the user is doing something directly on the page, for instance when a button is clicked: this is called an Inline Action. Setting them up only needs a little modifying of the events you implemented.

Example: Add to cart with a button.

Let's say you have a button used to add a product into a cart, that will do an Ajax call to update the user's cart without leaving the current page. You'll need to trigger the event anyway, so you want to add it when the user clicked on the button.

Example button:

<buttonid="myAddToCartButton">Add to cart</button>

Instead of doing this:

<script>
  fbq('track', 'AddToCart', {
    value: 90,
    currency: 'EUR',
  });
</script>

You can do this on the same page as the button's one:

<scripttype="text/javascript">
$('#$myAddToCartButton' ).click(function() {
 fbq('track', 'AddToCart', {
    value: 90,
    currency: 'EUR',
  });
</script>

It means that when the button will be clicked, the event will be sent to Facebook directly!

Did this answer your question?