How do you set the Facebook Pixel
using an app that is made on Cordova
. I need to track conversions in the app so I can better target the ads made in Facebook
Ads. Normally it will be easy to do this task in an HTML page by copy pasting it and executing a JavaScript command, or in an app by installing the Facebook SDK
and running a command using JAVA, Swift or Objective-C. However Ionic opens a web view where the user is not connected to Facebook, so it does not track it. So what is the way to go?
In your Facebook Ads Manager, click on the menu button in the top-left corner and click All Tools at the bottom of the menu. Then under the Assets column, click Pixels. This opens the pixels dashboard. Under Conversion Tracking Pixel (Old), click the Create Conversion button.
A conversion pixel is a piece of code that is provided to advertisers to place on a website landing page. It allows brands to track and report on the actions of users who visit their page after viewing or clicking on an ad.
Add the Javascript from Facebook SDK Pixel into www/index.html (for permanent changes edit src/index.html)
<!-- 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', 'XXXXXXXXX');
fbq('track', 'PageView');
</script>
<noscript>
<img height="1" width="1"
src="https://www.facebook.com/tr?id=XXXXXXX&ev=PageView
&noscript=1"/>
</noscript>
<!-- End Facebook Pixel Code -->
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With