Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save leo8nardo8/a78c2a45063ac361911c709cd114b2b8 to your computer and use it in GitHub Desktop.

Select an option

Save leo8nardo8/a78c2a45063ac361911c709cd114b2b8 to your computer and use it in GitHub Desktop.
Initiates and configures Facebook Pixel with Advanced Matching parameters and tracks specified events.
<!--
!!! Even if you already trigger your pixel you have to re-initiate the pixel to populate the Advanced Matching properties.
Use case: Send 'Lead' event with 'Email' parameter for Advanced Matching purpose.
Advanced Matching documentation: https://developers.facebook.com/docs/meta-pixel/advanced/advanced-matching/
Standard Events Reference: https://developers.facebook.com/docs/meta-pixel/reference/
-->
<script>
fbq('init', '<your_pixel_ID>', {
'em': '<user_email>', // User email, values will be hashed automatically by the pixel using SHA-256
'fn': '<user_first_name>', // First name
'ln': '<user_last_name>' // Last name
// There is 11 parameters options, check the documentation
});
fbq('track', '<event_name>', { // Replace <event_name> for the desired event
parameter: '{{parameter}}' // Replace <parameter> and var {{parameter}} for the appropriate information
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment