Before starting the implementation of the Meta CAPI, ensure you have the following requirements:
• TAGGRS Setup: Ensure your TAGGRS server container is deployed. You can follow our implementation guide to have it done easily.
• API Access token: Generate in Meta Events Manager under Conversions API → Settings.
• Pixel ID: Locate in Meta Events Manager under Data Sources.
• Data Layer Configuration: Ensure your website sends data to the server GTM container via GA4.
go to Templates and select Search Gallery.
Facebook Conversion API from stape and click Add to workspace.
Create a new tag in your server container and select Facebook Conversions API as the tag type.
Configure the essential settings:
Choose between the following 2 options.
• Inherit from client: Automatically matches GA4 events to Meta standard events
• Override: Gives you full control over event configuration and payload customization
Set to Website for web-based conversions.
Enter your access token or use a variable like {{Meta Access Token}}.
Enter your Pixel ID or use a variable like {{Meta Pixel ID}}.
Check Generate _fbp cookie if it not exist for better event matching.
Set up User Data and Custom Data sections for enhanced tracking.
The Stape template automatically handles most data mapping, but you can enhance it with custom variables:
Variable type
Variable name
Purpose
Data Layer Variable
Event Name
Maps to event_name from client
Data Layer Variable
Transaction ID
Maps to ecommerce.transaction_id
Data Layer Variable
Purchase Value
Maps to ecommerce.value
Data Layer Variable
Currency
Maps to ecommerce.currency
Data Layer Variable
User Email
Maps to user_data.email_address
Data Layer Variable
User Phone
Maps to user_data.phone_number
Create a Custom trigger that fires when your data client processes events. Set the trigger condition:
The stape template automatically maps common GA4 events to Meta standard events:purchase → Purchaseadd_to_cart → AddToCartbegin_checkout → InitiateCheckoutpage_view → PageView
Enable Consent Settings if using consent management:
• Configure to send data only when marketing consent is granted.
• Ensure your web container passes consent status to the server container.
The template handles automatic event deduplication when configured with matching event IDs between client-side and server-side implementations.
graph.facebook.com in POST - 200.If you’re experiencing Facebook CAPI errors related to the contents or content_ids parameters, this section explains why the issue occurs and how to fix it correctly.
When sending events to Meta via Facebook CAPI, you may encounter the following error in Events Manager:
{"error":{"message":"Invalid
parameter","type":"OAuthException","code":100,
"error_subcode":2804008,"is_transient":false,
"error_user_title":"Invalid Contents Parameter",
"error_user_msg":"The contents parameter you entered
doesn't contain a list of JSON objects. Enter a
list of JSON objects that contain the product
IDs associated with the event plus information
about the products. For example: [{ 'id' :
'ABC123', 'quantity' : '2', 'item_price' : 5.99},
{ 'id' : 'XYZ789' , 'quantity' : 2, 'item_price'
: 9.99}]","fbtrace_id":"..."}}This typically indicates that the contents parameter is either malformed or not formatted as a list of JSON objects.
contents and content_ids Go to your server container in your tag manager. Locate your existing Facebook CAPI tag. Remove the following parameters (if present): contents and content_ids.
contents parameter for Purchase EventsFacebook expects contents to be an array of product objects. The safest approach is to build it in the web container using GA4 e-commerce data.
So, create a JavaScript Variable in your client container:
• Open your web container.
• Add a new variable of type Custom JavaScript.
• Use the following code to construct the contents parameter (Make sure {{DLV - ecommerce.items}} is your correct items variable):
function() {
// Access the items array from the dataLayer
var items = {{DLV - ecommerce.items}};
// Validate that items is an array with at
least one item
if (!items || !Array.isArray(items) ||
items.length === 0) {
return null;
}
// Map over each item to create a new array
with the modified properties
var modifiedItems = items.map(function(item) {
return {
id: item.item_id,
name: item.item_name || "",
price: item.price || 0,
quantity: item.quantity || 1
};
});
// Return only the first item in
the modified array as required
return [modifiedItems[0]];
}This ensures that the JSON structure is valid, required product fields are included, and everything is compatible with Meta’s CAPI validation rules.
In the server container:
• Create a dedicated Facebook CAPI tag for purchase events.
• Exclude purchase events from the original Facebook CAPI tag.
In the purchase-specific CAPI tag:
• Add the contents parameter.
• Use an Event Data variable to pull the contents value from the variable you created earlier in the web container.
Publish both the web container and the server-side container.
Test all events (e.g., Add to Cart, Purchase) to confirm that they are functioning as expected.
Check Meta Event Manager to ensure no errors appear.