Send any event to Facebook

Published July 07, 2022
Modules
Difficulty
Selected Clients
ccc logoorange logocarrefour logo

You can relay any events collected by Synerise to Facebook Conversion API in order to enrich the customer’s history and create more personalized ads in Facebook.

Example events:

  • page visits
  • adding a product to cart
  • clicking a recommendation
  • prediction results
  • many more, including your own custom event types

In this use case, we will send page.visit events to Facebook using the dedicated integration node in Automation.

Note: Completing this procedure requires some knowledge on sending API requests using tools such as curl or Postman.

Prerequisites


Create a workflow


In this part of the process, you will create a workflow that is triggered by an event. Through the outgoing integration, the system sends this event to Facebook.

Add the Profile Event trigger

In this part of the process, you will configure the trigger of workflow. Whenever the event in trigger happens, the system launches the workflow and performs action configured in it - in our case it will be sending event to Facebook.

  1. In the Synerise app, go to Automation > Workflows > New workflow.
  2. On the dashboard, click the plus button.
  3. From the dropdown list, select Profile Event.
  4. Double-click the Profile Event node.
  5. On the pop-up, from the Choose event list, select the page visit event. If you’re not sure of the event’s label in your system, search for page.visit (or other event you want to send to Facebook).
  6. Confirm by clicking Apply.
Configuration of the Profile Event trigger
Configuration of the Profile Event trigger. No conditions are used, all page.visit events activate the trigger.

Configure Facebook Integration node

In this part of the process, you will configure an action that workflow performs - outgoing integration that sends the event to Facebook. Values of the event parameters will be dynamic and will be passed from the event trigger using inserts.

  1. On the Profile Event node, click the plus icon.
  2. From the dropdown list, select Facebook.
  3. From the dropdown list, select Send custom event.
  4. Click the node.
  5. Click Select connection.
  6. From the dropdown list, select the connection.
    If you haven’t established a connection yet, see Create a connection.
Configuration of the Facebook Integration node
Final configuration of the Facebook Integration node

Create a connection

Use an access token which allows you to send a request.

  1. At the bottom of the Select connection dropdown list, click Add connection.
  2. In the Access token field, enter the app access token.
    Note: You can read more about access tokens in Facebook documentation.
  3. Click Next.
  4. In the Connection name field, enter the name for the access token you generated.
  5. Click Apply.
    Result: A connection is created and selected.

Define the integration settings

  1. In the Graph API version field, enter the currently used API version in Facebook.
    You can find information about the currently used API version in the Facebook documentation.
  2. In the Meta Pixel ID field, enter the identifier of the Pixel you use in Facebook.
    You can find information about how to find ID of the Pixel in the Facebook documentation.
  3. In the Event data input field, enter the JSON body of event. Use inserts to insert dynamic values and Facebook developer documentation to build the structure of event body.

Example of page.visit event body:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
{   "data": [
    {
        "event_name": "PageVisit",
        "event_time": {{ (event.params.time / 1000)|int }},
        "event_source_url": "{{ event.params.uri }}",
        {% if event.params['product:retailer_part_no'] %}
            "currency": "PLN",
            "content_type": "product",
            "content_ids":  ["{{ event.params['product:retailer_part_no'] }}"],
            "value": {{ event.params['product:price:amount']|int }},
        {% endif %}
        "user_data": {
            "client_ip_address": "{{ event.params.ip }}",
            "client_user_agent": "",
            "em": ["{% if 'anonymous' in client.email %}{% else %}{{ client.email|trim|lower|hash("SHA-256") }}{% endif %}"],
            "ph": ["{% if 'phone' in customer|string %}{{ client.phone|trim|lower|hash("SHA-256") }}{% endif %}"],
            "fbc": "",
            "fbp": ""
        },
        "custom_data": {}
    }]
}

where:

Line number Description
4 Inserts event time from the trigger node and re-calculates it into seconds (this is required by Facebook).
5 Inserts URI from the trigger node as the event_source_url param.
6-11 If the visited page has product metadata, inserts that metadata.
13 Inserts customer’s IP from the trigger node.
15 Inserts email encoded using SHA-256 algorithm, if available.
16 Inserts phone number encoded using SHA-256 algorithm, if available.
Important: In the example of body described above, you can see that customer’s personal data is encoded. While sending events to Facebook, the customers’ identifiers must be encoded using SHA-256 algorithm. Read more about encoding function in inserts.
  1. Confirm by clicking Apply.

Add the End node

  1. On the Send custom event node, click the plus button.
  2. From the dropdown list, select End.
  3. Save and activate the automation by clicking Save&Run.
  4. Go to your Facebook Ad account, select Facebook Manager > Events Manager to see the events.
The final structure of the workflow
The final structure of the workflow

Result: After the customer performs event trigger, the webhook.response event is visible on the customer’s profile with 200 status. That means that the event has successfully been sent to Facebook.

Check the use case set up on the Synerise Demo workspace


You can also check the workflow configuration directly in Synerise Demo.

If you don’t have access to the Synerise Demo workspace, please leave your contact details in this form, and our representative will contact you shortly.

Read more


😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker