How to set up Facebook pixel submit button tracking?

How to set up Facebook pixel submit button tracking?

It is quite easy to avoid tracking links, maybe affiliate links and you want to hide those links and track only “terms” that can be set from a simple Javascript function.

Here is a code that can be integrated inside your Facebook Pixel code that should be placed before the /head html tag.

1
2
3
4
function purchase_track() {
    // track term Purchase
    fbq("track", "Purchase", {"value":"80", "currency": "CAD"});
      }

And you will have to add for your links that you want to track, when being clicked, this onclick code:

2
<a href="https://incvice.com" onClick="purchase_track();">track this link</a>

You can tweak this further, change the term “Purchase” into anything you want. Change the value, currency etc. It just requires some basic Javascript knowledge or you can just change what you see in this example.

Here is an example of a full Facebook Pixel code which also has the onclick function integrated.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '333811173041321');
fbq('track', 'PageView');
 
function purchase_track() {
    // purchase track
    fbq("track", "Purchase", {"value":"10", "currency": "CAD"});
      }
 
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=333811173041321&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->

And as mentioned previously, you also need to add the “onclick” function to all your links that you want to track for the term inside the Javascript function.

Add a comment: