facebook-marketing-apifacebook-pixel

Sending User Data Parameters via Pixel


I have some user data parameters from Facebook's Marketing API (https://developers.facebook.com/docs/marketing-api/server-side-api/parameters/user-data#external-id) that I wish to send using Pixel (fbq function)

Let's take one of the user data parameter - external_id I am currently doing something like this -

fbq('track', 'AddToCart', {external_id: 1234})

The documentation on the aforementioned url states that you can send these values using fbq('init') function, but I wasn't sure if its applicable with fbq('track') function too.

On another note, recently I got this mail from facebook that "Your server is sending the external_id parameter for your AddToCart event inside the custom_data field section of your payload. External_id is invalid unless it is sent as user data field"

What could be the reason for it? the documentation states you don't need to wrap external_id inside user_data field if sending through pixel. Is this issue message incorrect?


Solution

  • I didn't have any issues passing the external_id. Maybe look at the snippet, you might have an error in there. Here's what I am using for the Page View event.

    <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', 'XXXXXXXXXXXXXXX', {
          'em':'some@email.com', // Email
          'external_id': user12345 // User ID
          });
      fbq('track', 'PageView');
    </script>

    Page View Pixel Result