Facebook Conversion API showing Server event as Browser

Viewed 41

Been getting weird results from my FB CAPI in Facebook's event test tool.

Is it Facebook's bug or something is wrong with my payload?

Here's what I'm doing and I've been able to replicate this on different machines on different IPs.

Here's how I can replicate the problem a lot of the times:

  1. I open the Event test tool for my pixel in Business Manager. I open Graph API Explorer to send test events to the above mentioned Event Test tool.
  2. In Graph API Explorer I enter my Access Token. I use the following JSON code to send a test payload to Event Test tool:
{
  "data": [
    {
      "event_name": "ViewContent",
      "event_time": 1661938013,
      "event_id": "1661886269650_16619383723281",
      "event_source_url": "https://example.com/?gtm_debug=1661936451103",
      "action_source": "website",
      "user_data": {
        "client_ip_address": "111.111.111.111",
        "client_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
        "em": null,
        "ph": null
      },
      "custom_data": {
        "contents": null
      }
    }
  ],
  "partner_agent": "gtmss-1.0.0-0.0.5",
  "test_event_code": "TEST83629"
}
  1. I then check Event Test tool and see the following message received: enter image description here

  2. Like you can see from the above screenshot, the event name is CUSTOM EVENT (blank), event though it was sent as a standard ViewContent. Also, the source is marked as WEBSITE, when obviously it was sent through Graph API and should be marked as SERVER.

  3. I then go back to Graph API Explorer and change ONE NUMBER of client_ip_address to something like "112.111.111.111" and send the same payload again.

  4. I check Event Test tool and this time I see the following message received: enter image description here

WHY the same payload reacts so differently and is even marked as received from a WEBSITE, even though was sent through SERVER? And why does fiddling with IP sometimes fix the problem?

I've been able to replicate this issue with already three different users. Three different Business accounts and Three different pixels. What am I doing wrong?

1 Answers

I had encountered same issue. Also when using the same server-side GTM template: Conversions API Tag

The issue is that in your payload you are sending "em" and "ph" parameters under "user_data" as null. This somehow confuses the API. These values must either be a hashed string or not be defined at all.

See - https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/customer-information-parameters/

Edit the Conversions API Tag template code. Find these lines:

// Commmon Event Schema Parameters
event.user_data.em = eventModel['x-fb-ud-em'] ||
                        (eventModel.user_data != null ? hashFunction(eventModel.user_data.email_address) : null);
event.user_data.ph = eventModel['x-fb-ud-ph'] ||
                        (eventModel.user_data != null ? hashFunction(eventModel.user_data.phone_number) : null);

and replace them with:

let emData = eventModel['x-fb-ud-em'] || (eventModel.user_data != null ? hashFunction(eventModel.user_data.email_address) : null);
if(emData != null) {
  event.user_data.em = emData;
}

let phData = eventModel['x-fb-ud-ph'] || (eventModel.user_data != null ? hashFunction(eventModel.user_data.phone_number) : null);
if(phData != null) {
  event.user_data.ph = phData;
}

This will make it so the data is not added at all if its not defined, instead of adding a null.

Related