搜索插件、代码仓与 APP 分类

插件详情v0.0.6

facebook_event

用于 Facebook 应用事件的 Flutter 插件。

AndroidiOS
近 30 天下载
36
喜欢数
31
Pub 分数
115

安装插件

flutter pub add facebook_event

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

facebook_event 包是一个 Flutter 插件,可实现与 Facebook 应用事件的集成,用于跟踪用户交互和应用分析。它允许开发者在 Android 和 iOS 平台上的 Flutter 应用中直接记录购买、注册和自定义操作等事件。该插件通过提供跨平台的一致 API 简化了事件跟踪,确保营销和性能分析的数据准确收集。它在底层使用官方 Facebook SDK,因此可靠且始终符合 Facebook 的要求。此包非常适合希望优化广告活动并借助详细分析了解用户行为的应用。

适合场景

  • 跟踪应用内购买
  • 监控用户注册
  • 分析用户参与度
  • 优化广告活动表现
  • 测量转化率

主要特点

  • 跨平台支持(Android 和 iOS)
  • 简单事件日志 API
  • 与 Facebook SDK 集成
  • 实时事件跟踪
  • 对自定义事件和标准事件的支持

适合对象

  • 电子商务应用
  • 以营销为重点的应用程序
  • 使用 Facebook 广告的应用程序
  • 数据驱动开发
  • 具有用户转化目标的移动应用

使用建议

  • 需要设置 Facebook 应用 ID
  • 需要适当的权限和隐私合规性
  • 依赖于 Facebook SDK 更新
  • 可能需要额外配置以支持深度链接
  • 不适用于非Facebook分析用例

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

facebook_event

pub package

Flutter plugin for Facebook Event and Analytics.

Facebook Events is a feature that can help you organize social gatherings via Facebook. You get a dedicated page for providing all the details of your event plus a range of tools to notify friends about it and keep track of who's going. Facebook Events are different from Facebook Groups and Facebook Pages.

Facebook Analytics is a robust tool that lets marketers explore users' interactions with advanced goal paths and sales funnels for Facebook ads. In this article, you'll discover how to get started with Facebook Analytics.

Installation

You must first create an app at Facebook for developers: https://developers.facebook.com/

Get your app id (referred to as [APP_ID] below)

Android

Read through the "Getting Started with App Events for Android" tutuorial and in particular, follow step 2 by adding the following into /app/res/values/strings.xml (or into respective debug or release build flavor)

After that, add that string resource reference to your main AndroidManifest.xml file, directly under the <application> tag.

<meta-data
  android:name="com.facebook.sdk.ApplicationId"
  android:value="your_facebook_app_id_here" />

Example Code

Add code in your android project MainActivity.kt

setAutoLogAppEventsEnabled(true)
FacebookSdk.setAutoInitEnabled(true)
FacebookSdk.fullyInitialize()
setAdvertiserIDCollectionEnabled(true)
FacebookSdk.setIsDebugEnabled(true);
FacebookSdk.addLoggingBehavior(LoggingBehavior.APP_EVENTS);

Example Code

iOS

Read through the "Getting Started with App Events for iOS" tutuorial and in particular, follow step 4 by opening info.plist "As Source Code" and add the following

If your code does not have CFBundleURLTypes, add the following just before the final </dict> element:

<key>CFBundleURLTypes</key>
<array>
  <dict>
  <key>CFBundleURLSchemes</key>
  <array>
    <string>fb[APP_ID]</string>
  </array>
  </dict>
</array>
<key>FacebookAppID</key>
<string>[APP_ID]</string>
<key>FacebookDisplayName</key>
<string>[APP_NAME]</string>

If your code already contains CFBundleURLTypes, insert the following:

<array>
 <dict>
 <key>CFBundleURLSchemes</key>
 <array>
   <string>fb[APP_ID]</string>
 </array>
 </dict>
</array>
<key>FacebookAppID</key>
<string>[APP_ID]</string>
<key>FacebookDisplayName</key>
<string>[APP_NAME]</string>

Example Code

Add code in your android project AppDelegate.swift

ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
AppEvents.activateApp()
AppEvents.logEvent(AppEvents.Name.init(rawValue: "Opened App Main VC"))

Example Code

Get Android HashKey
final facebookEvent = FacebookEvent();
String hashKey='Null';

@override
void initState() {
    // TODO: implement initState
    super.initState();
    if(Platform.isAndroid)
      getHashKey();
}

void getHashKey()async{
    hashKey= await facebookEvent.getAndroidHashKey();
    print(hashKey);
}
All Events
final facebookEvent = FacebookEvent();

// Get facebook application id
facebookEvent.getApplicationId();

/// An app is being activated, typically in the AppDelegate's applicationDidBecomeActive.
facebookEvent.logActivatedApp();

// This event when an app is being deactivated.
facebookEvent.logDeactivatedApp();

// Re-enables auto logging of app events after user consent
facebookEvent.setAutoLogAppEventsEnabled(true);

// Submit user details
facebookEvent.setUserData(
  email:'email',
  firstName:'first name',
  lastName:'last name',
  phone:'phone number',
  dateOfBirth:'dob',
  gender:'gender',
  city:'city',
  state:'state',
  zip:'zip',
  country:'country',
);

// Submit custom event
facebookEvent.logEvent(
    name: 'name',
    body: {'key':'value'},
    valueToSum: 0
);

// Submit contact details
facebookEvent.logContactEvent(contact: 'number');

// A user has viewed a form of content in the app.
facebookEvent.logViewContent(
  content: {'key':'value'},
  id: 'id',
  type: 'type'
);

// The user has completed a purchase. The FB.LogPurchase method is a shortcut for logging this event. specified currency.
facebookEvent.logPurchase(
  amount: 0,
  currency: 'USD',
  body: {'key':'value'}
);

// The user has achieved a level in the app.
facebookEvent.logAchieveLevelEvent(
  level: 'level'
);

// The user has entered their payment info.
facebookEvent.logAddPaymentInfoEvent(
  success: true
);

// The user has added an item to their cart. The valueToSum passed should be the item's price.
facebookEvent.logAddToCartEvent(
  price:0,
  contentData: 'contentData',
  contentType: 'contentType',
  contentId: 'contentId',
  currency: 'USD'
);

// This event when the user has completed registration with the app.
// A user has completed registration with the app.
facebookEvent.logCompleteRegistrationEvent(
  registrationMethod:'registrationMethod',
  name: 'name',
  currency: 'USD'
);

// The user has entered the checkout process. The valueToSum passed should be the total price in the cart.
facebookEvent.logInitiateCheckoutEvent(
  totalPrice:0,
  contentData: 'contentData',
  contentType: 'contentType',
  contentId: 'contentId',
  currency: 'USD',
  numItems: 1,
  paymentInfoAvailable: true
);

// The user has rated an item in the app. The valueToSum passed should be the numeric rating.
facebookEvent.logRateEvent(
  ratingGiven:5,
  contentData: 'contentData',
  contentType: 'contentType',
  contentId: 'contentId',
  maxRatingValue: 5
);

Documentation

You will find all the FB.LogAppEvent details here.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。