This document will describe how users can be added/removed to/from an audience by firing FB Custom Events through APC.

The Facebook (FB) Pixel provides several different means for adding and removing users to and from an audience based on the different actions that the user takes during their visit to a site, and it is mainly being controlled through triggering different FB Events. Users within a given audience can be included/excluded on the basis of these FB Events having fired or not within a given time period.

Here, we are making a distinction between Apsis Profile Cloud (APC) Events and FB Events. These aren’t to get mixed up - the APC Event is used to determine when to trigger a FB Event towards the FB API.

Adding/Removing Users to a Facebook Audience through Profile Cloud

In order to add/remove users to/from an audience through APC, two APC Events will be needed firing to trigger two different FB Events within FB for including/excluding the user from the audience in question.

Adding a user to a Facebook Audience by firing the pixel (Profile Cloud)

In order to start adding users to a given audience, an event needs to be prepared within APC to trigger at the desired interaction/moment.

Let us start by creating an example event that can be used for testing the tag. A new event can be created by going to Collect -> Web Data Collection, then clicking the Events tab (next to Dashboard), and click “Create new event definition”.  A dialogue box will then open asking for an Event name, ID and category.

Figure 2.1.1: Event creation dialogue box

As can be seen in figure 2.1.1, the event name used in this example is “Frequent Visitor” and the category used is “social media”. The ID will be filled out automatically as the event name is being entered. A short description is also being used to describe the event. This is not a requirement, however.

This event will will trigger as the user lands on the site and match a segment of being a frequent visitor. The event will extract two profile attributes: “Lifetime Total Spend”, the total amount spent by the user on our site during the profile lifetime, and “Favorite Product Category”, their favorite product category (determined either by survey or through scoring). Lastly, a FB Custom Event will be sent to FB containing information on what type of event that has taken place and what relevant data that has been collected together with it.

For the event, an appropriate trigger is needed. In this example we will use the Page Load trigger (see figure 2.1.2). This means that the event will trigger as the page is loaded.

Figure 2.1.2: Adding the Page Load trigger to the event

We will then need to add a segment to our event, to make sure that it only fires for users that belong to this segment. In this case, we will add a “Frequent Visitor” segment (see figure 2.1.4). This segment includes anyone that has had five “New Visit” (APC) events during the latest month, thus making them frequent visitors.

Figure 2.1.4: Our segment

Within each event that is meant to add a user to a given audience, the FB Custom Event tag is also needed. This tag can, as with the Page Load trigger, be found in the left hand menu of the event builder page (see figure 2.1.4). Once the tag has been found in the menu, drag and drop it (or double-click it) and place it within the Tags area of the event builder.

Figure 2.1.4: Adding the Custom Event tag to the event

Now we have an FB Custom Event that will fire as the page is loaded for anyone that is a frequent visitor. However, we need to do one more thing to fulfill our exempel case: we need to collect the data that we want to send along as parameters for the FB Custom Event.

By using the Get Profile Attribute building block (BB), we can extract any profile attribute from the profile to send to the tag. In this case, we are interested in two profile attributes: “Lifetime Total Spend” and “Favorite Product Category”. Add these to the event and then connect them to the tag (see figure 2.1.5).

Figure 2.1.5: Connecting the two BBs to the tag

The last thing to do is to fill out the tag parameters properly. The tag has seven available parameters: Event Name, together with three optional (static or dynamic) custom parameters (name and value) that can be sent along with the request (see figure 2.1.5). For our exemple case, we only need two of these three custom parameters. Preferably, the Restrict per session condition is also added to the event to prohibit from triggering with each page being loaded.

The Event Name parameter is used to tell FB what type of Custom Event has just been fired and it is a required parameter. Here, we will use “FrequentVisitor” as the event name. As Custom parameter 1 name we will use “lifetime_total_spend” to signal to FB the name of the first parameter of the Custom Event. As Custom parameter 1 value we will use our dynamic value for the Lifetime Total Spend profile attribute which we connected to the tag earlier. The same process goes for the Custom parameter 2 name (and value), but here we use “favorite_product_category” as the name (and the corresponding profile attribute as the value). Since we don’t have any third parameter, we will live this one blank. The order of these parameters is completely arbitrary.

Figure 2.1.5: The FB Custom Event parameters

Removing a user from a Facebook Audience by firing the pixel (Profile Cloud)

Here, the procedure is essentially the same as when adding users to the audience: an event needs to be fired at the intended time as the user has taken a desired action on the site, but here we remove them from the same FB Audience instead. What controls the exclusion of users from segments is, as with the inclusion of a user, the Custom Event name and/or its parameters. Also, as with the event that adds user to the audience, a condition is preferably added to make sure that a Custom Event is only generated once per session.

A good example of when a user should be removed/excluded from the same audience we just added a user to is when he/she lands on the site and isn’t considered as a frequent visitor anymore. For this flow, we can create an event, use the same trigger (Page Load), add the same segment but negated instead (see figure 2.2.1), and lastly add the Custom Event tag with the Event Name “NonFrequentVisitor” (see figure 2.2.2). No custom parameters will be needed here.

Figure 2.2.1: Negating the “Frequent Visitor” segment

Figure 2.2.2: “Non-Frequent Visitor” Custom Event parameters

Preparing the Audience in the Ads Manager (Facebook)

In order to be able to add the users to an audience, a new website traffic audience has to be created and configured to include users that have triggered our “FrequentVisitor” Custom Event and to exclude those that have triggered the “NonFrequentVisitor” event. This can be done by creating a Custom Audience with corresponding inclusion/exclusion rules for the mentioned Custom Events (see figure 2.3.1).

Figure 2.3.1: Setting up the FB Audience

This should lead to the audience being kept balanced as frequent users are added to the audience as soon as they interact with the site and match the APC Segment “Frequent Visitors”, and excluded once they land on the site and don’t match the segment anymore.

Validating that requests are being sent to Facebook

By opening the Network tab in your browser (after triggering the APC Event and without reloading/changing the page) and filtering the traffic on “facebook”, you should be able to see the request being sent with a 200 OK status code in the response. (see figure 3.1).

Figure 3.1: Request sent to FB