Facebook Pixel conversions

DocsHow to › Facebook Pixel conversions

Last updated: 26 Jun 2018 / 1:03 PM / GMT

Are you looking to promote your live event or premium asset on Facebook? Then you should make use of their conversion optimisation feature to make sure your money is well spent.

Optimise your Facebook ads by sending conversion events using your Facebook Pixel code.

The short explanation of how this is done is that you use the InPlayer activity functions to trigger the events that Facebook is looking for to be allowed to see exactly how your ads are performing. We’ll walk you through how to set this up on your page. The example we chose to use is how you set up your Facebook Pixel to track the ad type Facebook call “Conversions”. If you are looking for other types of event tracking – take a look at all the actions available on our Action Function page.

Suggested conversion funnel

By adding the Facebook Pixel to your page it will automatically track visits to the page; the ‘PageView’. When tracking conversions to optimise ads on Facebook you can choose to submit 9 different event types to your Pixel.  The ones we feel are most relevant for conversions through a paywall purchase flow are ‘InitiateCheckout’ and ‘Purchase’. Purchase can be submitted with some additional information to set a value to your conversion.

If your main campaign purpose is to track the amount of new users then there is an option to also use the ‘CompleteRegistration‘ event.

Adding Facebook tracking to your code

Here’s an example of what this looks like. To see the basics and what functions are available, please read through the documentation for the paywall Action Functions.

Step 1. Add your Facebook Pixel to the head

First of all, make sure you have your Facebook Pixel code set up in the <head> part of your page. (If you copy paste this, make sure you remember to edit your Facebook ID both in the init and the image.)

<head>

<!– InPlayer Injector code –>

<script type=’text/javascript’ src=’https://assets.inplayer.com/injector/staging/injector.js’></script>
<link rel=’stylesheet’ href=’https://assets.inplayer.com/injector/staging/css/app.min.css’ type=’text/css’ media=’all’>

 

<!– 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’, ‘1234500000000000’);

fbq(‘track’, ‘PageView’);
</script>
<noscript>
<img height=”1″ width=”1″
src=”https://www.facebook.com/tr?id=1234500000000000&ev=PageView
&noscript=1″/>
</noscript>
<!– End Facebook Pixel Code –>

</head>

Step 2. Add your events to the inplayer.inject

The code that goes in the header should be the same for any page you add paywalled assets to. The following part should go in the body and is unique to each asset you want to track. More specifically the asset ID is unique, but the Facebook tracking can be the same.

In this example we’ve added tracking for when someone clicks the buy now button, then registers a NEW account and then once a successful payment goes through.

<body>

<div id="inplayer-00000"></div>
<script type="text/javascript"> 

inplayer.inject("00000", "00000000-0000-0000-0000-000000000000"

onInit: function(e){
document.getElementsByTagName(‘body’)[0].addEventListener(‘click’, function(e){
if (e.target.className.indexOf(‘inplayer-paywall-‘) >= 0){

// FACEBOOK PIXEL
fbq(‘track’, ‘InitiateCheckout’);

}
});
}
onRegister: function(e){

// FACEBOOK PIXEL
fbq(‘track’, ‘CompleteRegistration’);

},

onPayment: function(e){

// FACEBOOK PIXEL EVENT: fbq(‘track’, ‘Purchase’, {value: ‘0.00’, currency: ‘USD’});

// make sure to edit the ticket value and the currency
fbq(‘track’, ‘Purchase’, {value: ‘20.00’, currency: ‘USD’});
}

);

</script>

</body>

 

We use cookies to analyse our traffic. We also share information about your use of our site with our analytics partners. See details