Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 693
Rahul Ranjan Avatar asked Aug 07 '26 14:08

Rahul Ranjan


1 Answers

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':'[email protected]', // Email
      'external_id': user12345 // User ID
      });
  fbq('track', 'PageView');
</script>

Page View Pixel Result

like image 67
thecrentist Avatar answered Aug 11 '26 05:08

thecrentist



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!