Skip to main content

Facebook Analytics Capacitor plugin

Meta/Facebook App Events analytics with standard events, purchase logging, currency parameters, and advertiser tracking controls

Install

bun add @capgo/capacitor-facebook-analytics bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-facebook-analytics
  • pnpm add @capgo/capacitor-facebook-analytics
  • yarn add @capgo/capacitor-facebook-analytics

Guide

How to use Facebook Analytics in Capacitor

Using @capgo/capacitor-facebook-analytics

Meta/Facebook App Events analytics for Capacitor apps on iOS and Android.

Install

bun add @capgo/capacitor-facebook-analytics
bunx cap sync

What This Plugin Exposes

  • initAppEvents - Activate Facebook App Events manually.
  • logEvent - Log standard or custom App Events with parameters, value, and currency.
  • logPurchase - Log purchase events with amount and currency.
  • enableAdvertiserTracking - Enable native advertiser tracking where supported.
  • disableAdvertiserTracking - Disable native advertiser tracking where supported.
  • getAdvertiserTrackingStatus - Read the current advertiser tracking status.
  • getPluginVersion - Read the native plugin version.

Example Usage

logEvent

Log a standard event with Facebook parameters.

import {
  FacebookAnalytics,
  FacebookEventName,
  FacebookEventParameterName,
} from '@capgo/capacitor-facebook-analytics';

await FacebookAnalytics.logEvent({
  event: FacebookEventName.CompletedRegistration,
  params: {
    [FacebookEventParameterName.RegistrationMethod]: 'email',
  },
});

logEvent with value and currency

Send value-bearing standard events with the fb_currency parameter.

import {
  FacebookAnalytics,
  FacebookEventName,
  FacebookEventParameterName,
} from '@capgo/capacitor-facebook-analytics';

await FacebookAnalytics.logEvent({
  event: FacebookEventName.AddedToCart,
  valueToSum: 19.99,
  currency: 'USD',
  params: {
    [FacebookEventParameterName.ContentType]: 'product',
    [FacebookEventParameterName.ContentId]: 'sku-123',
  },
});

logPurchase

Log a purchase event.

import { FacebookAnalytics } from '@capgo/capacitor-facebook-analytics';

await FacebookAnalytics.logPurchase({
  amount: 9.99,
  currency: 'USD',
});

Full Reference

Keep going from Using @capgo/capacitor-facebook-analytics

If you are using Using @capgo/capacitor-facebook-analytics to plan native plugin work, connect it with @capgo/capacitor-facebook-analytics for the implementation detail in @capgo/capacitor-facebook-analytics, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.

FAQ

Facebook Analytics plugin FAQ

How do I install the Facebook Analytics plugin in a Capacitor app?

Run "bun add @capgo/capacitor-facebook-analytics" (or "npm install @capgo/capacitor-facebook-analytics"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-facebook-analytics" in your app code.

Does @capgo/capacitor-facebook-analytics work with React, Vue and Angular?

Yes. Facebook Analytics is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-facebook-analytics support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-facebook-analytics free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-facebook-analytics/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses Facebook Analytics without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship Facebook Analytics changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo