Created
December 28, 2018 18:23
-
-
Save ai2ik/c607113a90a8f156b6c621197c0e85d6 to your computer and use it in GitHub Desktop.
After you install the pixel track in-page actions, such as product purchases, by tying events to HTML elements such as buttons. For example:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button onClick="fbq('track', 'Purchase');">Button Text</button> | |
Or you could create a function that pushes the event. The advantage is if you have multiple HTML elements, you can call a single function when someone clicks any of them; you don't have to define individual onClick element. | |
For example, to push the event: | |
<script> | |
function onClick() { | |
fbq('track', 'Purchase'); | |
}; | |
</script> | |
You can call this function to fire Purchase events from multiple HTML elements. For example: | |
<button onClick="onClick()">Buy Now</button> | |
<button onClick="onClick()">Buy as a Gift</button> | |
Note: Pixel Helper may show multiple pixel events firing from the same page. The Pixel Helper expects pages to fire only on load but by tying events to elements, such as a button, you are using an alternative solution that overturns the expected behavior. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment