Démarrage
Copiez une commande de configuration avec les étapes d'installation et la guide markdown complète pour ce plugin.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-facebook-analytics`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/facebook-analytics/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
Installer
Installationbun add @capgo/capacitor-facebook-analyticsbunx cap syncImporter
Section intitulée « Importer »import { FacebookAnalytics, FacebookEventName, FacebookEventParameterName,} from '@capgo/capacitor-facebook-analytics';Configuration native
Configurez votre ID d'application Meta et votre jeton client dans l'application native. Le plugin ne crée pas ces valeurs pour vous.iOS
Section intitulée « iOS »
Ajoutez vos valeurs Meta àCopier dans le presse-papier Info.plist:
<key>FacebookAppID</key><string>YOUR_FACEBOOK_APP_ID</string><key>FacebookClientToken</key><string>YOUR_FACEBOOK_CLIENT_TOKEN</string><key>FacebookDisplayName</key><string>YOUR_APP_NAME</string>Android
Section intitulée “Android”Ajoutez vos valeurs Meta à AndroidManifest.xml:
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id" /><meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token" />Ajoutez les ressources de chaîne dans android/app/src/main/res/values/strings.xml:
<string name="facebook_app_id">YOUR_FACEBOOK_APP_ID</string><string name="facebook_client_token">YOUR_FACEBOOK_CLIENT_TOKEN</string>Activer le suivi de l'annonceur
Section intitulée “Activer le suivi de l'annonceur”Appelez cela après que votre flux de consentement autorise le suivi.
await FacebookAnalytics.enableAdvertiserTracking();Sur iOS 17 et au-dessus, FBSDK v17+ lit directement la transparence du suivi de l'application. Utilisez votre flux de suivi de l'application avant d'enregistrer les événements dépendants du suivi.
Enregistrer un événement standard
Section intitulée « Loguer un événement standard »await FacebookAnalytics.logEvent({ event: FacebookEventName.CompletedRegistration, params: { [FacebookEventParameterName.RegistrationMethod]: 'email', },});Loguer un événement de valeur avec devise
Section intitulée « Loguer un événement de valeur avec devise »await FacebookAnalytics.logEvent({ event: FacebookEventName.AddedToCart, valueToSum: 19.99, currency: 'USD', params: { [FacebookEventParameterName.ContentType]: 'product', [FacebookEventParameterName.ContentId]: 'sku-123', },});Loguer une vente
Section intitulée « Loguer une vente »await FacebookAnalytics.logPurchase({ amount: 9.99, currency: 'USD',});Lire l'état de suivi
Section intitulée « Lire l'état de suivi »const { status } = await FacebookAnalytics.getAdvertiserTrackingStatus();console.log('Advertiser tracking enabled:', status);Source de vérité
Section intitulée « Source De Vérité »Cette page est générée à partir du plugin's src/definitions.tsRe-faites la synchronisation lorsque les données publiques API changent en amont.