Scaledrone Blog
Feb 11th, 2018

Facebook Pixel Tracking Across Multiple Domains

A typical situation for a SaaS website is to have your public web on and have your actual app on

This approach makes sense for many best practices on the web but does not work so well with Facebook Pixel tracking.

The iframe approach

A handy way and possibly the only way to get around the multiple domains or subdomains issue is to inject an iframe into the subdomain.

To track a signup event on, you first need to create a new page containing the Facebook Pixel tracking code on

The page will be very minimal since any user never sees it.

<!DOCTYPE html>
    <meta name="robots" content="noindex">
    <!-- Facebook Pixel Code -->
      s.parentNode.insertBefore(t,s)}(window, document,'script',
      fbq('init', 'xxxxxxxxxxxxxxx');
      fbq('track', 'CompleteRegistration');
      <img height="1" width="1" style="display:none" src="">
    <!-- End Facebook Pixel Code -->

Note that we also added the robots meta tag to prevent search engines from indexing this page.

Next, add this line to your page.

<iframe src="" style="width:0;height:0;border:none;"></iframe>

That's it 🎊! Use this approach to track users across multiple domains for your website.



By default, your web server or balancer might not allow for iframes from other domains or subdomains. Fix that with the Content-Security-Policy response header.

Content-Security-Policy: frame-ancestors '*'
Scaledrone is a realtime messaging service and platform.
Send live updates, create chatrooms and collaborative tools.
Try Scaledrone for free