RodrigoSMarques / flutter_branch_sdk

Flutter Plugin for create deep link using Branch Metrics SDK. This plugin provides a cross-platform (iOS, Android, Web).
https://branch.io
MIT License
98 stars 89 forks source link

PURCHASE and INITIATE_PURCHASE is not being tracked in facebook ads #139

Closed RicardoRB closed 2 years ago

RicardoRB commented 2 years ago

Describe the bug PURCHASE and INITIATE_PURCHASE is not being tracked in facebook ads

To Reproduce Steps to reproduce the behavior:

  1. Create PURCHASE or INITIATE_PURCHASE
  2. BranchEvent.standardEvent(BranchStandardEvent.INITIATE_PURCHASE)
  3. There is no way to send more than 1 buo
  4. Log is not being tracked

Expected behavior FlutterBranchSdk.trackContent(#buo,#event) can receive a list of buo

Smartphone (please complete the following information):

Additional context Just need to send more than one buo, I believe that it shouldn't be complicated instead of getting one or create another method that receive more than one buo

RodrigoSMarques commented 2 years ago

I didn't understand the problem.

Is the event not tracked or do you need to send two buo?

Please send more information.

About the possibility of sending two buo, this package (plugin) uses Branch's native SDK (ios/android/web). All methods in the package call the respective methods in the native SDK.

To be able to send two buo, it is necessary to verify that the native SDK has this functionality on all platforms.

I have to analyze.

RicardoRB commented 2 years ago

Sorry, I didn't describe the problem that good.

I can not track the purchase or checkout by facebook ads. I believe the reason is that the library is not sending the parameters that facebook ads needs.

Furthermore, I believe one of the reasons is that PURCHASE and INITIATE_PURCHASE require a list of products and at the moment flutter_branch_sdk just provide the possibility to send 1.

Here, you can find more information about how to configure branch in different apps: https://help.branch.io/developers-hub/docs/measuring-in-app-events#purchase

Example for iOS:

TuneEventItem *item1 = [TuneEventItem eventItemWithName:@"ball1" unitPrice:3.99 quantity:2];
TuneEventItem *item2 = [TuneEventItem eventItemWithName:@"ball2" unitPrice:9.99 quantity:1 revenue:9.99 attribute1:@"red" attribute2:@"inflatable" attribute3:@"rubber" attribute4:nil attribute5:nil];
NSArray *eventItems = @[item1, item2]; // HERE IS WHAT I MEAN

[Tune setUserId:@"US13579"];
[Tune setFacebookUserId:@"321321321321"];
[Tune setGoogleUserId:@"11223344556677"];
[Tune setTwitterUserId:@"1357924680"];

TuneLocation *loc = [TuneLocation new];
loc.latitude = @(9.142276);
loc.longitude = @(-79.724052);
loc.altitude = @(15.);
[Tune setLocation:loc];

TuneEvent *event = [TuneEvent eventWithName:TUNE_EVENT_PURCHASE];
event.eventItems = eventItems; // HERE IS INITIALIZED
event.refId = @"ref13571";
event.revenue = 13.97;
event.currencyCode = @"USD";

[Tune measureEvent:event];

Here you can find the map and required from branch to facebook ads: https://help.branch.io/using-branch/docs/facebook-ads-overview#metadata

Unfortunately, I don't know how you do it with the metadata and the bue class.

Let me know if something isn't clear and I would try to add more info.

RodrigoSMarques commented 2 years ago

Hi. I'm still investigating, today or morning I'll report the analysis.

RodrigoSMarques commented 2 years ago

Hi @RicardoRB

I have checked the Branch SDK and it is possible to send a BUO list to BranchEvent.standardEvent. I will develop this functionality in the next few days.

About Facebook ADS (Purchase Events), talking to the Branch team it was suggested that you open a support ticket with them via the URL.

The support team will be able to further investigate what is happening.

RicardoRB commented 2 years ago

Thank you @RodrigoSMarques

It's weird since the other standard event are working, except for checkout and purchase. I don't believe they can help me to configure anything, since I believe it may be a problem with this library that I don't know what parameters should I send to make it work.

RodrigoSMarques commented 2 years ago

I understand, but it was guidance I received from the Branch team itself.

If it's something that has to be implemented in the package, they'll let you know and probably me too.

RicardoRB commented 2 years ago

This is my code, maybe someone can see if I'm doing something wrong:

    final event =
        BranchEvent.standardEvent(BranchStandardEvent.INITIATE_PURCHASE);
    event.currency = BranchCurrencyType.EUR;
    event.revenue = price;
    event.addCustomData("providerId", providerId);
    if (transactionId?.isNotEmpty == true) {
      event.transactionID = transactionId!;
    } else {
      event.transactionID = const Uuid().v4();
    }

    event.addCustomData("fb_payment_info_available", 1);

    final metadata = BranchContentMetaData()
      ..sku = itemIds.first
      ..quantity = numItems.toDouble()
      ..price = price
      ..currencyType = BranchCurrencyType.EUR
      ..productName = itemIds.first
      ..productCategory = BranchProductCategory.FOOD_BEVERAGES_AND_TOBACCO;

    final buo = BranchUniversalObject(
      canonicalIdentifier: itemIds.first,
      title: itemIds.first,
      contentMetadata: metadata,
    );
    FlutterBranchSdk.trackContent(
      buo: buo,
      branchEvent: event,
    );
jf-branch commented 2 years ago

Hey @RicardoRB,

This is Justin, I'm the PM of SDKs and public APIs here at Branch. If you're not receiving an error client-side, and the events are being properly ingested within Branch's dashboard, and the only issue is it seems either Commerce events are not being forwarded to Facebook or Facebook is not ingesting the commerce events.

Regardless, our event postbacks to Ad Partners or Data Lakes all occur server-side and our support team has the tooling required to investigate further. Please file a support ticket here: https://help.branch.io/using-branch/page/submit-a-ticket so the team can investigate your event ingestion and event postbacks.

RodrigoSMarques commented 2 years ago

@RicardoRB

I released a new version 5.0 adding support to send a BUO list in FlutterBranchSdk.trackContent.

RicardoRB commented 2 years ago

Amazing! Thanks! Closing it then :)