Graph API Version

Offsite Pixel

Reading

This feature can be accessible before v2.9. You could also use the Facebook Pixel instead.

After you create a pixel you should get the code that you're going to use in your website by making an HTTP GET call to

https://graph.facebook.com/<API_VERSION>/<PIXEL_ID>

Considerations

  • The value parameter in the JS code returned in the response from Facebook is set to the standard denomination format for that currency. For instance, for USD this field is defined in dollars, not cents. The currency defaults to the currency of your ad account, or you can specify your own currency by following the instructions here.
  • You need a pixel for each type of offsite event that you want to track. For example, if you want to track REGISTRATION and CHECKOUT follow the procedure above for each one of these events.
  • If you want to piggy back the Facebook conversion tracking pixel off a tag manager and can only use an HTML version, please copy and use the HTML component of the JS code snippet which is found between <noscript> and </noscript>
  • The pixel works on all webpages, including mobile web and canvas apps.
  • If you are using a Doubleclick container tag, use the HTML version of the Facebook pixel

Example

Graph API Explorer
GET /v4.0/{offsite-pixel-id} HTTP/1.1
Host: graph.facebook.com
/* PHP SDK v5.0.0 */
/* make the API call */
try {
  // Returns a `Facebook\FacebookResponse` object
  $response = $fb->get(
    '/{offsite-pixel-id}',
    '{access-token}'
  );
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();
/* handle the result */
/* make the API call */
FB.api(
    "/{offsite-pixel-id}",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);
/* make the API call */
new GraphRequest(
    AccessToken.getCurrentAccessToken(),
    "/{offsite-pixel-id}",
    null,
    HttpMethod.GET,
    new GraphRequest.Callback() {
        public void onCompleted(GraphResponse response) {
            /* handle the result */
        }
    }
).executeAsync();
// For more complex open graph stories, use `FBSDKShareAPI`
// with `FBSDKShareOpenGraphContent`
/* make the API call */
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                               initWithGraphPath:@"/{offsite-pixel-id}"
                                      parameters:params
                                      HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                      id result,
                                      NSError *error) {
    // Handle the result
}];
If you want to learn how to use the Graph API, read our Using Graph API guide.

Parameters

ParameterDescription
value
int64

The value, in minimum currency unit, of the transaction that the pixel is tracking. Defaults to the currency of the ad account

Fields

FieldDescription
id
numeric string

ID of the conversion pixel

creator
string

ID and name of the ad account that first created the pixel

js_pixel
string

JavaScript code for the pixel that you should place in the head of the conversion page

last_firing_time
datetime

Last time the pixel was fired

name
string

Name of the conversion pixel

tag
string

One of: checkout, registration, lead, key_page_view, add_to_cart, other

Validation Rules

ErrorDescription
100Invalid parameter

Creating

Examples

Create a pixel

curl \
-F "name=NAME" \
-F "tag=CHECKOUT" \
-F "access_token=___" \
"https://graph.facebook.com/<API_VERSION>/act_<AD_ACCOUNT_ID>/offsitepixels"

You can't perform this operation on this endpoint.

Updating

You may edit the metadata of a pixel one field at a time.

Examples

Modify the value field of the pixel code to $1.50 for a USD account.

curl \
-F "value=150" \
-F "access_token=_____" \
"https://graph.facebook.com/<API_VERSION>/<PIXEL_ID>"

You can't perform this operation on this endpoint.

Deleting

You can't perform this operation on this endpoint.