1
votes

I am using the Marketing API, the Insights Edge specifically, to retrieve the data of our campaigns.

https://developers.facebook.com/docs/marketing-api/insights/v2.4

The problem is that I do not see the field for knowing how many app installs the ad has generated.

I see "clicks, impressions, reach" fields but nothing about the number of downloads from the stores.

Is there a way to know that? This is available in the Facebook Ads dashboard but I do not see any way to get that value from the API.

Thanks for any help!!

require_once(__DIR__ . "/config/config.php");
include_once(__DIR__ . "/inc/helpers.php");
require __DIR__ . '/vendor/autoload.php';

use FacebookAds\Api;
use FacebookAds\Object\AdAccount;
use FacebookAds\Object\AdCampaign;
use FacebookAds\Object\Values\InsightsPresets;

$access_token = readFromFile(__DIR__ . "/auth/token.txt");

// Initialize a new Session and instanciate an Api object
Api::init($app_id, $app_secret, $access_token);
// The Api object is now available trough singleton
$api = Api::instance();

$account = new AdAccount('act_' . $ads_account_id);
$campaigns = $account->getAdCampaigns(array(
        \FacebookAds\Object\Fields\AdCampaignFields::ID,
        \FacebookAds\Object\Fields\AdCampaignFields::NAME,
    )
);


foreach ($campaigns as $campaign) {
    //echo $campaign->{\FacebookAds\Object\Fields\AdCampaignFields::ID}.PHP_EOL;

    $campaign_insights = new AdCampaign($campaign->{\FacebookAds\Object\Fields\AdCampaignFields::ID});
    $params = array(
        'date_preset' => InsightsPresets::YESTERDAY,
        /*
        'time_range' => array(
            'since' => '2015-08-03',
            'until' => '2015-08-03'
        ),
        */
        'filtering' => array(
            [
                'field' => 'campaign.objective',
                'operator' => 'IN',
                'value' => ["MOBILE_APP_INSTALLS"]
            ]
        )
    );
    $insights = $campaign_insights->getInsights(array(
        'reach',
        'impressions',
        'clicks',
        'call_to_action_clicks',
        'total_actions',
        'spend'
    ), $params);
1

1 Answers

5
votes

After trying every possibile field, I have found out that it's inside the "actions" field.

Thanks