skip to Main Content

I am trying to test server events of a Facebook pixel using Graph API.
I am getting this response.

 {
  "error": {
    "message": "Invalid parameter",
    "type": "OAuthException",
    "code": 100,
    "error_subcode": 2804019,
    "is_transient": false,
    "error_user_title": "Server Side Api Parameter Error",
    "error_user_msg": "Unexpected key "email" on param "$['data'][0]".",
    "fbtrace_id": "Ajfq0hd3gzSkADpWdh9210O"
  }
}

Can anyone help me with what I am doing wrong?

2

Answers


  1. the problem is that you need to send some data in has as suggested in the home page https://developers.facebook.com/docs/marketing-api/conversions-api/payload-helper the customer information must go in has according to quoted by facebook

    Customer Information Parameters
    Include at least one customer information parameter for each event you want to send. Facebook will use this data for the purposes described in its Business Tools Terms, including ads attribution and ads delivery optimization.
    All customer information parameters should be hashed as SHA256, except for client IP address, client user agent, click ID, and browser ID. Any other customer information parameters that are not hashed are automatically rejected by Facebook.

    Payload

        {
          "data": [
            {
              "event_name": "uno",
              "event_time": 1613600385,
              "event_source_url": "jksdhfkjsdhfkdjs",
              "action_source": "website",
              "user_data": {
                "em": "7b17fb0bd173f625b58636fb796407c22b3d16fc78302d79f0fd30c2fc2fc068",
                "ph": "7474b932bd08487ffc76773fdfd45ce84f3cbfccf2c8c2dcb7446836826c06cf"
              },
              "custom_data": {
                "currency": "USD",
                "value": "142.52"
              }
            }
          ],
          "test_event_code": "TEST99348"
        }
    
    Login or Signup to reply.
  2. The test_event_code, should be sent as the same token way.

    Php example:

    <?php
    $curl = curl_init();
    
    curl_setopt_array($curl, array(
      CURLOPT_URL => 'https://graph.facebook.com/v12.0/YOUR_PIXEL_ID/events',
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => '',
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 0,
      CURLOPT_FOLLOWLOCATION => true,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => 'POST',
      CURLOPT_POSTFIELDS => array('data' => '[{"event_name": "CompleteRegistration","event_id": "ev.123","event_time": "1633709956","action_source": "website", "user_data": {"client_ip_address": "70.80.XXX.XXX","client_user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1"},"custom_data": {"currency": "USD","value": 0.5,"websiteurl": "megaodds.net"}}]','access_token' => 'YOUR_TOKEN','test_event_code' => 'TEST86091'),
    ));
    
    $response = curl_exec($curl);
    
    curl_close($curl);
    
    echo $response;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search