Wpd Alpha Insights Data Source Facebook Campaigns

Alpha Insights Documentation

Docs Navigation

Filter: wpd_alpha_insights_data_source_facebook_campaigns

Filter the Facebook Ads (facebook_campaigns) entity data returned by the Facebook Campaigns data source before it is stored in the data warehouse.

Description

After the Facebook Campaigns data source builds its data (totals, data_by_date, categorized_data, etc.), this filter is applied. You can modify campaign metrics or add custom keys. The data warehouse then stores the returned value for the facebook_campaigns entity. Requires Facebook Ads integration setup.

Location

File: includes/classes/data-sources/pro/WPDAI_Facebook_Campaigns_Data_Source.php

Context: When returning Facebook campaigns data from the data source.

Parameters

Parameter Type Description
$facebook_campaign_data array Facebook campaigns data structure (totals, data_by_date, categorized_data, total_db_records, etc.)
$data_warehouse WPDAI_Data_Warehouse The data warehouse instance

Return

Type: array

The (possibly modified) facebook_campaigns data structure.

Example Usage

Add a custom total

add_filter( 'wpd_alpha_insights_data_source_facebook_campaigns', 'add_facebook_campaign_metric', 10, 2 );
function add_facebook_campaign_metric( $facebook_campaign_data, $data_warehouse ) {
    if ( isset( $facebook_campaign_data['totals'] ) && is_array( $facebook_campaign_data['totals'] ) ) {
        $facebook_campaign_data['totals']['effective_cpc'] = 0; // Compute from spend/clicks
    }
    return $facebook_campaign_data;
}

Related

Got A Question?

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Alpha Insights

Alpha Insights

The World's Most Advanced WooCommerce Profit Reporting Engine

5/5 – Trustpilot

Alpha Insights