1 year ago

#258462

test-img

Petya Naumova

How to verify domain with Facebook pixel in Angular application?

As far as I read in Facebook developers API, verifying domain with Facebook pixel for Angular app, is as it follows:

  1. First, you need to insert FB Pixel JS code into the page's header or footer.

       !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>');
    fbq('track', 'PageView');

  1. The only change you need to make to your code is to adjust how Facebook Pixel tracks PageViews with the History State API listener provided in the pixel.

My question is that - should I insert the fb pixel script between the head tags in the index.thml file of the Angular app, or it should be loaded dynamically by JavaScript in the app.component.ts? Will it work if it is loaded dynamically because it does not seem to work - the domain is not verified? Or the proper way is to add the script manually in the index.html?

angular

facebook-pixel

0 Answers

Your Answer

Accepted video resources