Auto-fill event parameters with Conversions API Parameter Builder
mainThe SDK includes the Conversions API Parameter Builder to automatically extract key event parameters from incoming HTTP requests. By calling .setRequestContext(request) on a ServerEvent, the SDK can auto-fill missing fields such as user_data.fbc, user_data.fbp, user_data.client_ip_address, event_source_url, and referrer_url at the time of sending.
Key Behaviors:
- Non-destructive: If you manually set a value, the Parameter Builder will not overwrite it.
- Automatic Hashing: Customer information (email, phone, etc.) in
UserDatais automatically normalized and SHA-256 hashed. - Gated by Preference: You can control which fields are allowed to be auto-filled using the
Preferenceclass.
const Preference = bizSdk.Preference;
const serverEvent = (new ServerEvent())
.setEventName('Purchase')
.setEventTime(Math.floor(Date.now() / 1000))
.setUserData((new UserData()).setEmail('joe@eg.com'))
.setActionSource('website')
.setRequestContext(request);
// Optional: gate which fields may be auto-filled (all default true).
// Order: fbc, fbp, client_ip_address, referrer_url, event_source_url.
// .setRequestContext(request, new Preference(true, true, true, true, false));