I'm built single page application with AngularJS. I want to track pageView this web app with Facebook Pixel. But on analytics board, Facebook Pixel ignore the url part after '#'. In this image every URL display in http://localhost/ .
Can I push custom pageView (remove #) to fix this?
For my case it works the following configuration:
<!-- 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', '<<PIXEL ID>>'); // Insert your pixel ID here. </script> <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=133095247279894&ev=PageView&noscript=1" /></noscript> <!-- DO NOT MODIFY --> <!-- End Facebook Pixel Code -->
Inject $window on the state controller
// Registration angular.module('app.module') .controller('LeadsController', ['$scope', '$state', '$window']); $window.fbq('track', 'InitiateCheckout'); //or Purchase/Leads/CompleteRegistration event
It works that way because basically fbq has is binded on window object. Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.