# Facebook

advanced expert team enterprise

Keitaro collects information about advertising campaign costs via Facebook and sends conversions to optimize ad campaigns on the source side. The integration transfers conversions to Facebook via API. To transfer conversions via pixel without using integration and API, use the FB Pixel instruction.

# Settings

Open Maintenance → Integrations, select Facebook integration:

# Adding an account

Click Add account

# Description of settings

  • Name. Name of the new integration.
  • Ad account ID. Account ID.
  • FB Token. Token for connecting to the advertising account via API, see how to connect a token.
  • Pixel ID. Pixel ID is used to send conversions via API, see instructions.
  • Conversions token. To send conversions via API, you need to generate a token, passed as a parameter during the API request, see See instructions for obtaining a token.
  • API version. Facebook API versioning.
  • Update every. Updating integration costs in a specified time interval.
  • Choose campaigns. Each FB integration is for one or more campaigns. Select from the list for which campaigns to update costs.
  • Use proxy. Make all requests to the FB API with a proxy.

# Working with the integrations list

  • Name. Displays the name of the added integration. Clicking on the name will open the integration editing form.
  • Status. The status of the added integration. Please note that creating a Facebook integration without adding a campaign will show an error.
  • Pull. Request to update costs for this integration with the Facebook account.
  • Clone. Ability to add a copy of the configured integration, along with the added "Mapping" statuses.
  • Pause / Resume. Pause or continue the work of the added integration.
  • Mapping. Setting up mapping of Facebook conversions by user target actions.
  • Delete. Deleting the selected integration in the tracker.

It is possible to search for added integrations by their names:

# Getting the account ID

Open Facebook Ads Manager and copy the ID:

# Getting an API token

  1. Log in to Facebook account.

Open the app page and click Create app

  1. On the next window click Next

  1. Select "Other" and click Next

  1. Choose "Business" and click Next

  1. Add the app name, enter the contact email and click Create app

  1. Open the app settings. Choose Marketing API

  1. Choose "Tools" from Marketing API

  1. Select all checkboxes and press the button to purchase a marker

  1. Copy the API token of the app

# Getting Conversions Token

Get parameters for filling out the Facebook integration fields, according to the instructions

Conversions Token - is taken from the setting up the direct integration of the Personal Account. Click Generate Access Token. See instructions for obtaining a token

WARNING

Copy and save the marker in a safe place. The marker is issued once and cannot be viewed again. Otherwise, reissue the marker.

# Use proxy

Without a proxy in the integration settings, requests are sent from the tracker server.

Facebook often imposes geographic or IP restrictions. Using a proxy allows you to:

  • Simulate access from the desired region (for example, to set up ads for certain countries).
  • Avoid blocking or captcha that may occur with frequent or automated requests.

For stable access to Facebook, use a proxy. To set up, go to the created integration or create a new one and select the Use proxy checkbox:

Add proxy data and click Save.

# Fixing connection errors for integration

The main reasons why users do not receive costs in the tracker and conversions on the source side:

  1. Outdated version of the integration API. Make sure you are using at least the latest current stable version of the tracker (Maintenance — Update Keitaro — Stable — Current version is up-to-date). This version of the tracker is compatible with version 18 of the Facebook API.

  2. Incorrect token for connecting to an advertising account via API. The page from which the correct token is taken looks like this:

  1. Missing Facebook parameters, such as {{adset.id}} for expenses and {fbclid} for conversions, in the Campaign settings in the Parameters section.

In the campaign link that you place in the source, you must add the campaign parameters, including {{adset.id}}, but {fbclid} must be removed from the link when adding to the source.

WARNING

The fbclid value is not passed by the placeholder from the source, it is generated automatically, so the content of the placeholder in the link will interfere with writing the label to the tracker.

Connect the parameters directly from the template, in the campaign settings:

If the parameters are not filled in or if macros other than template ones are used, expenses will not be recorded and conversions will not be sent:

If the traffic primarily goes to a remote site to which the tracker is connected using any integration script (KClient PHP; Tracking script; WordPress plugin), tags from the source template must be added to the site URL as domain.com?adset_id={{adset.id}}&...

  1. In the FB ad settings, a link to the campaign, or the integration site is inserted without additional parameters. When creating an ad, the tags that you receive when using the source must be added to a separate window for parameters.

# Setting up Keitaro to sending conversions and events in Facebook Ads Manager

  1. Create a campaign in the tracker. When creating a campaign, use the Facebook source template, save:

  1. Connect your campaign integration to your Facebook Ads Manager advertising account. See the settings above.
  2. In the integration settings, click Mapping. Select the desired statuses, and events that you want to send to Facebook Ads Manager

  1. Add Pixel ID and Conversions Token, according to the instructions above.

  2. Done! The integration is configured. When target clicks start appearing in the campaign with fbclid parameter (see section Reports — Clicks), send a postback to check:

# How to set up Facebook Ads Manager to get conversions

  1. The conversion is sent if the fbclid parameter is present:

  1. Open the Facebook Ads Manager page, go to your business account:

  1. Create an advertising campaign:

  1. In the Website URL section, specify the tracker's campaign link with the ID:

  1. Additionally, enter the URL with the tracker's parameters section:

WARNING

It is necessary to remove fbclid={fbclid} from URL Parameters when adding campaign parameters to Facebook. Leave the Keitaro campaign template unchanged.

  1. Publish your campaign. Pay attention to the campaign status in your Facebook Ads Manager Personal Account:

  1. After confirming the campaign, as targeted clicks begin to show, check the events in Account Overview section

# Sending additional parameters to Facebook

By default, Keitaro sends the following parameters to Facebook:

               'action_source' => 'website', // This parameter is sent by default and cannot currently be changed.
               'event_name' =>               // Event type specified in the integration setup mapping window.
               'event_time' =>               // Event occurrence time.
               'user_data' => [
                   'fbc' => click identifier,
                   'fbp' => browser identifier,
                   'client_ip_address' => click IP address,
                   'client_user_agent' => click user agent,
                   'country' => country determined based on click IP address,
                   'st' => region determined based on click IP address,
                   'ct' => city determined based on click IP address
                ]
1
2
3
4
5
6
7
8
9
10
11
12

There is an option to send additional parameters in user_data:

  • em - email,
  • ph - phone,
  • fn - first name,
  • ls - last name.

To send these parameters to Facebook in an incoming postback, you need to send the corresponding parameters to the tracker. Example:

http://your_tracker_domain.com/2a76c2a/postback?subid=3sh8so4er3&status=sale&payout=2.61&em=example@gmail.com&fn=John&ln=Snow&ph=+71234567890
1

# FAQ

Error "Not tied to the campaign."

The integration is not selected in the campaign's settings in Keitaro.

Error "Success" status, but costs are not updating.

Make sure there is adset.id parameter both in campaign's parameters in Keitaro and in Facebook link.

Integration shows an error.

Check the Facebook token, make sure it is not expired and valid for the account.

How does currency conversion work?

The tracker takes the currency from the Facebook account and converts it into the tracker's currency.

Costs update period.

The integration updates costs for the last 5 days.

The first update will be 30 days.