Search code examples
androidiosangularjsionic-frameworkhybrid-mobile-app

Facebook Pixel Conversion(Facebook Ads) not updated in Ionic framework


Got question about FB pixel(FB Ads).
Thing is I want to to do the tracking to see if user register APP. So I implement the tracking code in between of <head></head> tag in the index.html, and comment out the <img> tag and fbq('track', "CompleteRegistration");

<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','//connect.facebook.net/en_US/fbevents.js');

    fbq('init', 'FB-TRACKING-CODE');//change pixel id
</script>
<!-- <noscript> -->
    <!-- <img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=FB-TRACKING-CODE&ev=PageView&noscript=1"/> -->
<!-- </noscript> -->

Then I implement fbq('track', "CompleteRegistration"); in the controller, like this

$scope.register = function(userData, isValid) {
      window.fbq('track', "CompleteRegistration");}

So when user click register button, it will also update data in FB Ads. It should be simple as expected... But things just not going smoothly, now I ran into the problem that it won't update the data in FB Ads. So the question is why not being updated? which part I'm doing wrong?

Not working on both iOS and Android.

Thanks everyone.


Solution

  • I am afraid this is not possible using facebook pixels. The facebook pixel will register conversions, but facebook will not be able to link those conversions to the user that saw your ad, because ionic uses a webview where where the facebook user is not signed in.