NOTE: article to be updated, you might find the latest information directly on Facebook.
Pixel Events in Button and Advanced Scenario
If you want to track how many people clicked a certain button on your page, you have to use In-Page events. This could be the case when your conversion is not happening on a certain page (e.g., at www.myshop.com/checkout/success), but rather inside one URL.
You can track in-page actions such as clicks on a button by making a _fbq.push('track')
JavaScript call for the conversion Pixel through registering different event handlers on an HTML DOM element.
1) Create a new conversion Pixel for tracking the in-page action.
2) Install the Facebook conversion Pixel code to your website.
3) Add the following JavaScript code to your website with the right conversion pixel id
Conversion value
and currency
are optional fields. They can be defined as fixed by replacing val
and cny
directly in the Pixel code, or they can be set as function parameters to trackConversionEvent(val, cny)
triggered by the tracked in-page event.
<script type="text/javascript">
function trackConversionEvent(val, cny) {
var cd = {};
cd.value = val;
cd.currency = cny;
_fbq.push(['track', 'pixel id', cd]);
}
</script>
How to trigger the above conversion with conversion value of 10.00
and currency EUR
on a button click:
<button onClick="trackConversionEvent('10.00', 'EUR');" />