Introduction

In January 2020, Google made clear its intention to stop supporting third-party cookie tracking tools. Third-party cookies have been the backbone of the display and native advertising industry for over a decade. 

The Conversions API allows advertisers to send web events from their servers directly to Facebook. Server events are linked to a pixel and are processed like browser pixel events. This means that server events are used in measurement, reporting, and optimization in the same way as browser pixel events.

Requirements
There are 3 main requirements to implement Conversion API.

Pixel
Before implementing the Conversions API, make sure you have the Facebook pixel correctly implemented in your website. We recommend that you use the same pixel for your browser and server events.
– We already have a pixel account that is currently working.
– I have created a personal pixel account for this POC.

Business Manager
You also need a Business Manager to use the API. Business Manager helps advertisers integrate Facebook marketing efforts across their business and with external partners.
– We also have it.
– I created one for this POC.

Access Token
To use the Conversions API, you need an access token.
How to get access token, please follow this link: https://developers.facebook.com/docs/marketing-api/conversions-api/get-started#via-events-manager

Note: We need admin or developer privilege to generate an access token.
Note 2: To send test data we need to send PayLoad with additional parameter: {test_event_code: TEST6810}

Code
We can verify request and response from Payload helper: https://developers.facebook.com/docs/marketing-api/conversions-api/payload-helper

Using jquery I able to call FB conversion API and register events. But we are not going to use this approach because we do not want to expose the access key in the client side.

Call from JS:

let userAgentString = navigator.userAgent;

let jsonData = JSON.stringify({
“data” : [
{

“event_time”: Math.round((new Date()).getTime() / 1000),
“event_name”: “Purchase”,
“user_data”: {
“em”: “7b17fb0bd173f625b58636fb796407c22b3d16fc78302d79f0fd30c2fc2fc068”,
“ph”: null,
“client_user_agent”: userAgentString,
“fbc”: “fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890”,
“fbp”: “fb.1.1558571054389.1098115397”,
“client_ip_address”: “123.123.123.123”
},
“custom_data”: {
“currency”: “USD”,
“value”: 143
},
“event_source_url”: “http://munir/123“,
“action_source”: “website-test”
}
]
});

url = “https://graph.facebook.com/v10.0/2202122233251123/events?access_token=EAAEE0V4R624BAJwWj22CaNyvFP5ns3ctx4XU0n3IJMf9BAVZBBQ9HiBTNfv4jT6B8M4n1IU3Tsg6qUWPSARGbZCnfrMOv7BfZAeniT4BWQj6hq6ITtt1lRwm15d5kWiuE9TCgIYFE4Kt6gbnQsIOXpWYPZBGnqLrfSBQpxmtRlnoAWxv4zs7e3RtCzMolG8ZD“;

$.ajax({
url: url,
data: jsonData,
contentType: “application/json”,
dataType: ‘json’,
type : “POST”,
success: function(result){
console.log(result);
}
});

1. Introduction

https://developers.facebook.com/docs/marketing-api/conversions-api/set-up-conversions-api-as-a-platform

Before starting, it is important to understand the relationship between server events and the Facebook Pixel. Server events are sent via Conversions API, and used in measurement, reporting, and optimization in the same way as browser pixel events.

2. Raw event example to Facebook

https://developers.facebook.com/docs/marketing-api/conversions-api/

curl -X POST \
-F ‘data=[
{
“event_name”: “Purchase”,
“event_time”: 1616732932,
“user_data”: {
“em”: “309a0a5c3e211326ae75ca18196d301a9bdbd1a882a4d2569511033da23f0abd”,
“client_ip_address”: “123.123.123.123”,
“client_user_agent”: “$CLIENT_USER_AGENT”,
“fbc”: “fb.1.1554763741205.AbCdEfGhIjKlMnOpQrStUvWxYz1234567890”,
“fbp”: “fb.1.1558571054389.1098115397”
},
“contents”: [
{
“id”: “product123”,
“quantity”: 1,
“delivery_category”: “home_delivery”
}
],
“custom_data”: {
“currency”: “usd”,
“value”: 123.45
},
“event_source_url”: “http://jaspers-market.com/product/123“,
“action_source”: “website”
}
]’ \
-F ‘access_token=<ACCESS_TOKEN>’ \
https://graph.facebook.com/v10.0/<PIXEL_ID>/events

3. Tasks

1. Setup conversion API Account and get all data required for POST request – 8h

2. Setup pipeline in Sitecore for all required requests where to send server event – 6h

3. differentiate requests to events: View Page, Submit Application, EventRegistration Confirmarion – 3h

4. Implement Asynchronous call to Conversion API in Sitecore – 6h

5. Setup Interception in legacy for all required requests in legacy – 4h

6. differentiate requests to events: View Page, Submit Application, EventRegistration Confirmarion – 3h

7.  Implement Asynchronous call to Conversion API in Legacy – 4h

Previous post PowerShell scripts to get Sitecore User information
EXM Next post Sitecore EXM- Couldn’t lock the item