The Facebook connector allows you view adverts, list generated leads from ads as well as create and update custom audiences.
Within the workflow builder, highlight the Facebook connector.
In the Facebook connector properties panel to the right of the builder, click on the Authenticate tab and the 'New authentication' button.
This will result in a Tray.io authentication pop-up modal. The first page will ask you to name your authentication and select the type of authentication you wish to create ('Personal' or 'Organisational').
The next page asks you for your 'Client ID' and 'Client secret' credentials.
To get these credentials, you need to be registered as a Facebook developer and add Tray as an application in the Facebook developer portal.
To start the registration process while logged into your Facebook account, go to the Facebook for Developers website and click Get Started.
Click 'Next' to agree to Facebook's Platform Terms and Developer Policies.
Enter your phone number and verify your account using text message or phone call.
Select an occupation that most closely describes what you do for a living.
Now that you are registered, you can use the App Dashboard to create your first app.
To create the app, go to the Apps panel and click 'Create App'.
From the pop-up choose an app type that suits your application.
Enter the name of your app and an email address where you wish to receive important developer notifications. The email address can be different from the email address associated with your Facebook account. Once done click 'Create App'.
Re-enter your Facebook password to continue.
The next step is to add your app. Click the 'Set Up' button from the product with the name 'Facebook Login'.
You will be redirected to the 'Quickstart' page. From the left panel, click on the 'Facebook Login' link to expand the sub-menu. Click 'Settings' from the sub-menu.
The next step is to enter Tray.io's OAuth 2 settings URI. You can find this URI on Tray.io's platform by navigating to Services > Add service > OAuth 2 settings.
Add this URI
https://auth.tray.io/oauth2/token in the 'Valid OAuth redirect URIs' field and click 'Save changes'.
Now you have successfully added Tray.io as an application. To get the Client Id and Secret for this newly created app, click Settings > Basic from the left panel.
On this page, you can get your credentials.
Copy and paste these credentials to your Tray.io authentication pop-up window.
You can optionally select the service permissions of your choice and then click the 'Create authentication' button.
You will then be redirected to a Facebook login page. Login with your Facebook account credentials and continue.
Facebook will then ask you to grant permissions for the scopes selected in the previous screen. Press the 'Continue as Connector' button to grant the permissions.
The authentication has been successfully created and the Facebook connector can now be used.
Select the recently added authentication from the dropdown options now available.
Your connector authentication setup should now be complete.
It's important to note that due to Facebook's authentication system, tray.io has to ask users who have created an authentication on the platform to re-authenticate regularly. tray.io will send an email to the owner of the authentication warning that the authentication will expire soon. To re-authenticate, a link will be provided that will take you to the authentication page.
Click on the URL and it will take you to this page:
From here, follow the same steps that were discussed in the Authenticating with Facebook section.
It is important to note that if re-authentication does not occur, the connector will fail after the authentication expires and workflows will be affected by this.
It is important to note that some operations within the connector are dependant on certain permissions that the signed in Facebook user has. For example, to use the
List leads from ad operation, you will need to be page admin to access the lead data of an ad (https://www.facebook.com/business/help/766393076839635). If operations are not returning data you're expecting, check using the facebook documentation that permissions are set up correctly.
Example 1: List leads from ad.
This example will walkthrough how to list leads from a given ad. The first step is to add the Facebook connector to the workflow.
To list leads from an ad, the id of the ad we want to query needs to be provided. To find this ID, the operation list ads in ad account can be used. This will return data about all ads that belong to an ad account.
To use this operation, select the
List ads in ad account operation in the input panel.
An ad account then needs to be selected, this dictates what ads are listed.
The ID of the advertisement can the be collected from the result set manually, or JSONPaths can be used to get the data straight from the operation. Below the connector snake is used to retrieve the JSONPath:
The input for the
List leads from ad operation now looks like the following:
The workflow is ready to be ran. Below you can see that the workflow ran successfully and leads have been listed from a given ad.
Example 2: Creating a custom audience
This example will walkthrough how to create a custom audience. The first step is to add the Facebook connector to the workflow.
Create custom audience operation then needs to be selected.
The first steps that will be taken will be to provide some information about the custom audience. This includes the ad account that this audience will belong to, a name for the audience, a useful description about the audience and the customer file source.
The next step is provide a population for this custom audience. This is done by adding audience member objects to the array audience members.
Below you can see an example of on audience member object.
It is important to understand that if you did not want to include the same fields in every audience member object, you have to provide an empty string in the field you wish to leave out. An example below shows how in the next audience member, the
Birth year attribute wants to be left out. Using the tooltip, an empty string can be set. This will prevent any errors occurring when the workflow is ran.
Now the custom audience has been defined, the workflow is ready to be ran. As can be seen in the image below, the workflow ran successfully and a custom audience has been created in Facebook.
Facebook leads ad trigger
The Facebook leads ad trigger allows a user to receive a notification whenever a lead has been generated on a page. This trigger uses the same authentication as the core connector so you do not need to worry about creating another authentication to use the trigger. If you have not set up a authentication then please refer to the
Authenticating with Facebook section found in this doc. Below is a guide on how to use this trigger:
1. Select the Facebook leads ad trigger from the selection when creating a workflow
2. Once an authentication has been created or selected, the operation
Subscribe to Lead Gen Ads needs to be selected.
3. To use the trigger, a Facebook page that is managed by the user needs to be selected. A drop down is provided showing those pages that can be used.
4. Once the page has been selected, we can enable and save the trigger
Notifications sent by Facebook contain only the ID of the lead that was created. To get all associated data about the new Lead, the core connector will need to be used in the step after. The
Get Lead operation retrieves all information about a Lead from a given ID.