Setting Up The WooCommerce Meta Facebook Ads API

Alpha Insights Documentation

Meta (Facebook / Instagram) Ads API Configuration

What Does This Feature Do?

This feature does a number of things, it essentially bridges the data gap between your WooCommerce store and your Meta (Facebook / Instagram) advertising account.

This feature does a few things:

  1. It will automatically import expenses from your Facebook Ad spend to calculate your store’s profit reliably without intervention from you
  2. It will produce a report (a small sample of the report above) to display key metrics and overviews for your entire ad account and specific campaigns.
  3. We also use a unique query parameter tacking key to connect your Facebook Campaigns to your orders to enable us to report on the ACTUAL profit of a campaign. In short you need to add the following query parameters to your landing pages: meta_cid={{campaign.id}}, more on that below.

How Does This Feature Work?

This feature will connect your WooCommerce store the the Facebook Advertising API allowing you to connect your WooCommerce store data with your advertising activity.

In essence, this feature will download all reporting functionality from your Facebook ad account to track your ad spend & report on your campaign performance within your Alpha Insights installation.

The feature will also check every hour for any orders that have an associated campaign id, using the meta_cid query parameter key, allowing us to report on actual profit and products sold.

This feature does not have permission to make any changes to your ad account.

Once configured, it will run at least daily (you can configure the schedule), fetching for expense data and campaign performance in the background.

Setting Up Your API Connection

1. Login To The Facebook Ads API

Go to Alpha Insights > Settings > Facebook API

On this page you will find the Login WIth Facebook button, click this and follow the prompts.

Through this process you will be sent to our website, where we will authorize the connection, and then return you back to your WordPress installation.

2. Select A Facebook Ad Account

When you log into and authenticate your connection with the Google API, we fetch for all available ad accounts that you have access to under that google account, and store them for you to use for your API configuration.

When you return to your website after authentication, you should be presented with a dropdown list of ad accounts to select from, select your target ad account and click save.

If you do not have the appropriate permission to access that Facebook Ad Account within the Facebook Account you logged in through, it will not show up, so make sure that you have the relevant permissions on a particular ad account that you are trying to configure under the Facebook Account that you logged in to.

If you feel like you have not got the ad accounts available that you think you should, you can use the Fetch for Available Ad Accounts button which will re-check your account for available ad accounts that you have access to.

That’s it, once you see a green dot on both section then you are configured.

* You can only use one ad account per installation.

If you run into any issues, they will normally display as messages at the top of this settings page, or will be available at the bottom of this settings page under the error log.

3. Once You’re Configured You Should Fetch For Data:

After you have selected your ad account, you will be asked to fetch for all data. Click this to do an initial fetch, it will only search back through a maximum of 36 months – this is a limitation of the Facebook API.

There is also an automatic process that fetches and stores data daily in the background, to keep your data up to date at all times (you can adjust this call schedule in the settings as per below).

This will fetch and store all expenses and data points to be used in expense calculation and campaign reports.

This may take 5-10 minutes depending on how much data you have.

At this point the fetch will continue to run, so you can leave this page if you want.

Once your configuration is complete succesfully it should look like below.

Setting Up Alpha Campaign Profit Tracking

Enable Accurate Profit Tracking By Connecting WooCommerce Orders To A Facebook Campaign

Unfortunately Facebook does not allow us to automatically fetch this data via the API, so you need to tag the landing page URL of every campaign with a particular query parameter key that we will check, to capture the campaign ID correctly.

Add the following query parameters to your landing page URL: meta_cid={{campaign.id}}

E.g. Your landing page may look like this: https://yoursite.com/products/hat/?utm_campaign=yourcampaign&utm_source=facebook&meta_cid={{campaign.id}}

Facebook does occasionally change their dynamic parameters, so just make sure that {{campaign.id}} is correct.

A schedule will run in your website that will check orders every hour for the presence of this meta key, store it if found & then use this data in the Facebook Campaign Report.

The Settings

API Call Schedule

This determines how frequently we should fetch for data from your Facebook Ad Account. The more often you are fetching the more tolling it is on your server and potentially you could hit API rate limits, so if you’re concerned about performance i’d leave it to once a day.

This fetch will collect and store expenses and also collect campaign data and store it within a campaign custom post type.

Collect Campaign Insights

This True or False setting will decide whether or not we store campaign analytics as a custom post type, if set to no we will not collect any campaign data.

Collect Daily Ad Spend (Stored as an expense)

This True or False setting will decide whether or not we store expense data to be used in total store profit calculations.

Set this to false if you don’t want to store expenses.

Ad Spend Expense Category

This is the expense category in which we will store your Google Campaign Ad spend against, we will try create one, otherwise you can create one or select an existing one.

Request Timeout

You shouldn’t need to change this, but if you are having timeout issues (found in your error logs at the bottom of the settings page) you may like to adjust this.

You may need to increase this if you have a very large Facebook ad account that requires more time to fetch the data.

Number of Results to Collect Per Call

This is another setting to assist in debugging timeout issues, you shouldn’t need to change it, but if you are having timeout issues you may like to decrease this value.

Important Notes

Debugging

Any errors in the Facebook API will be logged and reported at the bottom of your Facebook API setting page within Alpha Insights.

Most errors are temporary, they are most likely to be timeout issues, which are not permanent and do not effect the ongoing capacity of your installation.

For any queries or concerns, you can reach us at support@wpdavies.dev

Available Data

The Facebook API will only allow us to fetch back through 36 months worth of data, anything prior to this cannot be access.