Changing the Facebook “tr” endpoint to send Facebook Events to another URL (GTM Server-Side – Conversion API)

As a caveat this is an **unofficial** way of achieving this as of this article’s writing…

The question is why would you even want to change where events are sent to in the first place?

For certain Server-Side implementations (e.g. GTM Server-Side implementations with the Facebook Conversion API) there is a need to send your events to a different url other than .

There is an unofficial and undocumented method that will allow you to do this out-of-box. I had to read the pixel code to find this out, but it seem to be an effective way to modify the endpoint that the Facebook Pixel sends to. In a sense, it is like the “transport_url” for GA.

To the JS endpoint in the FB pixel you can call the “set” function with “endpoint” then override the default server that “tr” calls are made to. So just add the following line before your fbq calls and it will override FB’s default endpoint URL:

  1. fbq('set', 'endpoint', '');

So how your pixel code could resemble would be. When you run the script you’ll see that the calls are now being made to the endpoint you added.

  1. !function(f,b,e,v,n,t,s)
  2. {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
  3. n.callMethod.apply(n,arguments):n.queue.push(arguments)};
  4. if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
  5. n.queue=[];t=b.createElement(e);t.async=!0;
  6. t.src=v;s=b.getElementsByTagName(e)[0];
  7. s.parentNode.insertBefore(t,s)}(window, document,'script',
  8. '');
  9. fbq('set', 'endpoint', '');
  10. fbq('init', '<YOUR_PIXEL_ID>');
  11. fbq('track', 'PageView');

Leave a Reply

Your email address will not be published.