Meta has provided a list of library SDKs in both client-side (JavaScript) and server-side (PHP, Java, Python, NodeJS, Ruby). These SDK libraries are intended to help developers improve the quality of Conversions API event parameters (for example, fbc, fbp, client_ip_address and other customer information parameters like em and ph), and enable advertisers to adhere to Meta’s best practices around generating these parameters.
This document includes an overview of both libraries, guidance on which library to use, and example use cases.
Client-side: The library and events live in the front end on the browser side. The libraries are implemented in JavaScript. Developers may integrate it in their web page directly.
Server-side: The libraries and events live in the back end on the server side. Depending on the language the backend uses, Meta provides libraries in different languages (PHP, Java, Python, NodeJS and Ruby).
All libraries can work independently. To maximize the potential for you or your customers, please review the recommendations here.
Parambuilder adheres to the best practices referenced in Meta’s developer documentation. It is implemented on the client-side (JavaScript) and server-side (PHP, Java, Python, NodeJS, Ruby).
The following use cases may be worth considering as you are building the solution.
Pairing the server-side parameter builder and client-side parameter builder may help maximize your potential to achieve high fbc and IPv6 coverage.
To do so, you’ll need to integrate two libraries together: server-side parameter builder and client-side parameter builder.
// Example Controller which processes all requests to example.com
// Start process
ParamBuilder paramBuilder = new ParamBuilder(Arrays.asList('example.com', 'yourDomain.com'));
// Input the request's full URL, such as: example.com?fbclid=xxxxx
// Process and get recommended updated cookie
List<CookieSetting> updatedCookieList =
paramBuilder.processRequest(
request.getHeader("host"), // example.com
request.getParameterMap(), // {'fbclid':['xxxxx']}
cookieMap,
request.getHeader("referer"),
request.getHeader("X-Forwarded-For"),
request.getRemoteAddr(),
); // optional: referer full url
// Save cookie from server side
for (CookieSetting updatedCookie : updatedCookieList) {
Cookie cookie = new Cookie(updatedCookie.getName(), updatedCookie.getValue());
cookie.setMaxAge(updatedCookie.getMaxAge());
cookie.setDomain(updatedCookie.getDomain());
response.addCookie(cookie);
}
// Get fbc, fbp, client_ip_address
String fbc = paramBuilder.getFbc();
String fbp = paramBuilder.getFbp();
String client_ip_address = paramBuilder.getClientIpAddress();
// Get Normalized and Hashed PII like email and phone number
String normalizedAndHashedEmail = paramBuilder.getNormalizedAndHashedPII(‘John_Smith@gmail.com’,’email’);
String normalizedAndHashedPhone = paramBuilder.getNormalizedAndHashedPII(‘(650)555-1212’,’phone’);
// Call CAPI endpoint
.....
.setFbc(fbc)
.setFbp(fbp)
.setClientIpAddress(client_ip_address)
.setEmail(normalizedAndHashedEmail)
.setPhone(normalizedAndHashedPhone)
....
Please review the Server-Side Parameter Builder Onboarding Guide or the README files linked within for some detailed examples.
Please review the Client-Side Parameter Builder Onboarding Guide or the README files linked within for some detailed examples.
_fbp and _fbc cookies as early as possible in the customer journey in your webpage. Ideally retrieve _fbp and _fbc cookies when loading your landing page. It’s not recommended to retrieve them only from down-funnel events or when certain events are triggered._fbc or _fbp cookie. _fbc is case sensitive; do not normalize or format the _fbc to lowercase.getIpFn functionality, we recommend retrieving the IPv6 address first, then fallback to the IPv4 address if the IPv6 address retrieval capability is not available from the user's client side.client_ip_address and save to a cookie. Later on you can use the server-side parameter builder to get the best available client_ip_address from both cookie and request to send to Meta using the Conversions API.